remove-last.html (1898B)
1 <!DOCTYPE html> 2 <title>Remove the last element on the fullscreen element 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="first"> 10 <div id="last"></div> 11 </div> 12 <script> 13 promise_test(async (t) => { 14 t.add_cleanup(() => { 15 if (document.fullscreenElement) { 16 return document.exitFullscreen(); 17 } 18 }); 19 const first = document.getElementById("first"); 20 const [, firstEvent] = await Promise.all([ 21 trusted_request(first), 22 fullScreenChange(), 23 ]); 24 25 assert_equals(document.fullscreenElement, first, "fullscreen element after first request"); 26 assert_equals(firstEvent.target, first, "first fullscreenchange event target"); 27 28 const last = document.getElementById("last"); 29 const [, secondEvent] = await Promise.all([ 30 trusted_request(last), 31 fullScreenChange(), 32 ]); 33 34 assert_equals(document.fullscreenElement, last, "fullscreen element after second request"); 35 assert_equals(secondEvent.target, last, "second fullscreenchange event target"); 36 last.remove(); 37 // Although /last/ was removed from the top layer synchronously, /first/ remains 38 // and becomes the new fullscreen element. 39 assert_equals(document.fullscreenElement, first, "fullscreen element immediately after removal"); 40 41 // The removal of the fullscreen element triggers exiting fullscreen, but those changes 42 // happen async when the event is fired. 43 const thirdEvent = await fullScreenChange(); 44 assert_equals(document.fullscreenElement, null, "fullscreen element after third event"); 45 assert_equals(thirdEvent.target, document, "third fullscreenchange event target"); 46 }); 47 </script>