element-request-fullscreen-and-remove-iframe.html (1960B)
1 <!DOCTYPE html> 2 <title> 3 Element#requestFullscreen() in iframe followed by removing the iframe 4 </title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script src="../trusted-click.js"></script> 10 <div id="log"></div> 11 <iframe allowfullscreen></iframe> 12 <script> 13 promise_test(async (t) => { 14 const iframe = document.querySelector("iframe"); 15 await new Promise((resolve) => { 16 iframe.onload = resolve; 17 iframe.src = "about:blank"; 18 }); 19 20 const iframeDocument = iframe.contentDocument; 21 document.onfullscreenchange = t.unreached_func( 22 "fullscreenchange event" 23 ); 24 document.onfullscreenerror = t.unreached_func("fullscreenerror event"); 25 iframeDocument.onfullscreenchange = t.unreached_func( 26 "iframe fullscreenchange event" 27 ); 28 iframeDocument.onfullscreenerror = t.unreached_func( 29 "iframe fullscreenerror event" 30 ); 31 await trusted_click(document.body); 32 const p = iframeDocument.body.requestFullscreen(); 33 const typeErrorConstructor = iframe.contentWindow.TypeError; 34 iframe.remove(); 35 // Prevent the tests from hanging if the promise never rejects. 36 const errorPromise = new Promise((_, reject) => 37 t.step_timeout(() => { 38 assert_unreached("Promise didn't reject."); 39 reject(new Error("Promise didn't reject.")); 40 }, 1000) 41 ); 42 await Promise.race([ 43 promise_rejects_js(t, typeErrorConstructor, p), 44 errorPromise, 45 ]); 46 assert_equals(document.fullscreenElement, null); 47 assert_equals(iframeDocument.fullscreenElement, null); 48 }, "requestFullscreen() in iframe followed by removing the iframe"); 49 </script>