move-to-iframe.html (1530B)
1 <!DOCTYPE html> 2 <title>Move the fullscreen element to another document</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></div> 9 <iframe></iframe> 10 <script> 11 promise_test(async (t) => { 12 t.add_cleanup(() => { 13 if (document.fullscreenElement) { 14 return document.exitFullscreen(); 15 } 16 }); 17 const div = document.querySelector("div"); 18 const iframe = document.querySelector("iframe"); 19 const [, event] = await Promise.all([ 20 trusted_request(div), 21 fullScreenChange(), 22 ]); 23 24 assert_equals(document.fullscreenElement, div); 25 assert_equals(event.target, div); 26 27 assert_equals(div.ownerDocument, document); 28 iframe.contentDocument.body.appendChild(div); 29 assert_not_equals(div.ownerDocument, document); 30 // Moving /div/ removes it from the top layer and thus the fullscreen 31 // element synchronously becomes null. 32 assert_equals(document.fullscreenElement, null); 33 34 div.onfullscreenchange = t.unreached_func( 35 "fullscreenchange fired on element" 36 ); 37 iframe.contentDocument.onfullscreenchange = t.unreached_func( 38 "fullscreenchange fired on other document" 39 ); 40 const secondEvent = await fullScreenChange(); 41 assert_equals(document.fullscreenElement, null); 42 assert_equals(secondEvent.target, document); 43 }); 44 </script>