tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

move-to-fullscreen-iframe.html (2209B)


      1 <!DOCTYPE html>
      2 <title>Moving fullscreen document's body into a fullscreen iframe</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/resources/testdriver.js"></script>
      6 <script src="/resources/testdriver-vendor.js"></script>
      7 <script src="../trusted-click.js"></script>
      8 <iframe allowfullscreen></iframe>
      9 <script>
     10  promise_test(async (t) => {
     11    t.add_cleanup(() => {
     12      if (document.fullscreenElement) {
     13        return document.exitFullscreen();
     14      }
     15    });
     16    const iframe = document.querySelector("iframe");
     17    await new Promise((resolve) => {
     18      iframe.onload = resolve;
     19      iframe.src = "about:blank";
     20    });
     21    const iframeDoc = iframe.contentDocument;
     22 
     23    // Enter fullscreen for the iframe's body element.
     24    await Promise.all([
     25      trusted_request(iframeDoc.body, iframeDoc.body),
     26      fullScreenChange(),
     27    ]);
     28 
     29    assert_equals(
     30      document.fullscreenElement,
     31      iframe,
     32      "document's initial fullscreen element"
     33    );
     34    assert_equals(
     35      iframeDoc.fullscreenElement,
     36      iframeDoc.body,
     37      "iframe's initial fullscreen element"
     38    );
     39 
     40    // Then, move the outer document's body into the iframe. This is an unusual
     41    // thing to do, but means that the iframe is removed from its document and
     42    // should trigger fullscreen exit.
     43    iframeDoc.documentElement.appendChild(document.body);
     44 
     45    // If we exit in an orderly fashion, that's all one can ask for.
     46    await fullScreenChange();
     47    assert_equals(
     48      document.fullscreenElement,
     49      null,
     50      "document's final fullscreen element"
     51    );
     52 
     53    // Because the iframe was removed, its browsing context was discarded and
     54    // its contentDocument has become null. Because that browsing context was
     55    // neither a descendant browsing context nor had an active document,
     56    // nothing at all was done with it in the exit fullscreen algorithm, so
     57    // its fullscreenElement is unchanged.
     58    assert_equals(iframe.contentDocument, null, "iframe's content document");
     59    assert_equals(
     60      iframeDoc.fullscreenElement,
     61      iframeDoc.body,
     62      "iframe's final fullscreen element"
     63    );
     64  });
     65 </script>