tor-browser

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

remove-first-sibling.html (2100B)


      1 <!DOCTYPE html>
      2 <title>Remove the first 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 /a/ now shouldn't do anything except remove it from the top
     32    // layer, which causes it to no longer match :fullscreen.
     33    a.remove();
     34    assert_equals(document.fullscreenElement, b, "fullscreen element immediately after removal of a");
     35    assert_false(a.matches(":fullscreen"), "a should no longer match :fullscreen immediately after removal");
     36    assert_true(b.matches(":fullscreen"), "b matches :fullscreen immediately after removal of a");
     37 
     38    // No fullscreenchange event should fire. If the removal triggered exiting
     39    // fullscreen the event would be fired after an async section and an
     40    // animation frame task, so wait until after that.
     41    document.onfullscreenchange = t.unreached_func("fullscreenchange event");
     42    await new Promise((resolve) => {
     43      requestAnimationFrame(resolve);
     44    });
     45  });
     46 </script>