tor-browser

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

remove-last-sibling.html (2124B)


      1 <!DOCTYPE html>
      2 <title>Remove the last of two sibling elements in the fullscreen stack</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 <div id="a"></div>
     10 <div id="b"></div>
     11 <script>
     12  promise_test(async (t) => {
     13    t.add_cleanup(() => {
     14      if (document.fullscreenElement) {
     15        return document.exitFullscreen();
     16      }
     17    });
     18 
     19    const a = document.getElementById("a");
     20    const b = document.getElementById("b");
     21    await Promise.all([trusted_request(a), fullScreenChange()]);
     22 
     23    assert_equals(document.fullscreenElement, a, "fullscreen element after first request");
     24    assert_true(a.matches(":fullscreen"), "a matches :fullscreen after first request");
     25 
     26    await Promise.all([trusted_request(b, a), fullScreenChange()]);
     27    assert_equals(document.fullscreenElement, b, "fullscreen element after second request");
     28    assert_true(a.matches(":fullscreen"), "a matches :fullscreen after second request");
     29    assert_true(b.matches(":fullscreen"), "b matches :fullscreen after second request");
     30 
     31    // Removing the fullscreen element (b) triggers exiting fullscreen. Some changes are
     32    // visible synchronously and the others come when the event fires.
     33    b.remove();
     34    assert_equals(document.fullscreenElement, a, "fullscreen element immediately after removal of b");
     35    assert_true(a.matches(":fullscreen"), "a matches :fullscreen immediately after removal of b");
     36    assert_false(b.matches(":fullscreen"), "b no longer matches :fullscreen immediately after removal");
     37 
     38    // A fullscreenchange event should fire and all state should be cleared.
     39    await fullScreenChange();
     40    assert_equals(document.fullscreenElement, null, "fullscreen element after event");
     41    assert_false(a.matches(":fullscreen"), "a no longer matches :fullscreen after event");
     42    assert_false(b.matches(":fullscreen"), "b no longer matches :fullscreen after event");
     43  });
     44 </script>