tor-browser

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

document-fullscreen-enabled-removing-allowfullscreen.sub.html (2093B)


      1 <!DOCTYPE html>
      2 <title>
      3    Document#fullscreenEnabled removing allowfullscreen after load and then
      4    navigating
      5 </title>
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id="log"></div>
      9 <iframe></iframe>
     10 <script>
     11    function requestStatus(iframe) {
     12        iframe.contentWindow.postMessage(
     13            "What is document.fullscreenEnabled?",
     14            "*"
     15        );
     16        return new Promise((resolve) => {
     17            window.addEventListener("message", function listener(e) {
     18                window.removeEventListener("message", listener);
     19                resolve(event.data);
     20            });
     21        });
     22    }
     23 
     24    promise_test(async (t) => {
     25        const iframe = document.querySelector("iframe");
     26        iframe.allowFullscreen = true;
     27        assert_true(iframe.allowFullscreen, "allowFullscreen is false");
     28        assert_true(
     29            iframe.hasAttribute("allowfullscreen"),
     30            "allowFullscreen attribute is present"
     31        );
     32        await new Promise((resolve) => {
     33            iframe.onload = resolve;
     34            const path = location.pathname.substring(
     35                0,
     36                location.pathname.lastIndexOf("/") + 1
     37            );
     38            iframe.src = `http://{{hosts[][]}}:{{ports[http][0]}}${path}resources/echo-fullscreenEnabled.html`;
     39        });
     40 
     41        assert_true(
     42            await requestStatus(iframe),
     43            "document.fullscreenEnabled in the iframe, before navigation"
     44        );
     45 
     46        iframe.allowFullscreen = false;
     47        assert_false(iframe.allowFullscreen, "allowFullscreen is false");
     48        assert_false(
     49            iframe.hasAttribute("allowfullscreen"),
     50            "allowFullscreen attribute is not present"
     51        );
     52 
     53        await new Promise((resolve) => {
     54            iframe.onload = resolve;
     55            iframe.contentWindow.location.href = iframe.src + "?2";
     56        });
     57 
     58        assert_false(
     59            await requestStatus(iframe),
     60            "document.fullscreenEnabled in the iframe, after navigation"
     61        );
     62    });
     63 </script>