tor-browser

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

document-exit-fullscreen-timing.html (1829B)


      1 <!DOCTYPE html>
      2 <title>Document#exitFullscreen() timing</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 <div id="log"></div>
      9 <script>
     10    promise_test(async (t) => {
     11        const div = document.querySelector("div");
     12        await trusted_request(div);
     13 
     14        await Promise.all([
     15            new Promise((r) => (document.onfullscreenchange = r)),
     16            document.exitFullscreen(),
     17        ]);
     18 
     19        // If fullscreenchange is an animation frame event, then animation frame
     20        // callbacks should be run after it is fired, before the timer callback.
     21        // The resize event should fire before the fullscreenchange event.
     22        const events = [];
     23        const callback = t.step_func((event) => {
     24            // fullscreenElement should have changed before either event is fired.
     25            assert_equals(
     26                document.fullscreenElement,
     27                null,
     28                `fullscreenElement in ${event.type} event`
     29            );
     30            events.push(event.type);
     31            if (event.type == "fullscreenchange") {
     32                step_timeout(t.unreached_func("timer callback"));
     33                requestAnimationFrame(
     34                    t.step_func_done(() => {
     35                        assert_array_equals(
     36                            events,
     37                            ["resize", "fullscreenchange"],
     38                            "event order"
     39                        );
     40                    })
     41                );
     42            }
     43        });
     44        document.onfullscreenchange = window.onresize = callback;
     45    }, "Timing of fullscreenchange and resize events");
     46 </script>