element-request-fullscreen-active-document.html (1489B)
1 <!DOCTYPE html> 2 <title> 3 Element#requestFullscreen() when the document is not the active document 4 </title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <div id="log"></div> 8 <iframe allowfullscreen></iframe> 9 <script> 10 promise_test(async (t) => { 11 const iframe = document.querySelector("iframe"); 12 const typeErrorConstructor = iframe.contentWindow.TypeError; 13 const documentBeforeNav = iframe.contentDocument; 14 15 documentBeforeNav.onfullscreenchange = t.unreached_func( 16 "fullscreenchange event" 17 ); 18 documentBeforeNav.onfullscreenerror = t.unreached_func( 19 "fullscreenerror event" 20 ); 21 22 await new Promise((r) => { 23 iframe.src = "/common/blank.html"; 24 iframe.onload = r; 25 }); 26 27 await promise_rejects_js( 28 t, 29 typeErrorConstructor, 30 documentBeforeNav.documentElement.requestFullscreen() 31 ); 32 33 // Per spec the fullscreenerror event should be fired at the next animation 34 // frame, but at least Gecko and WebKit will instead effectively do "queue a 35 // task to fire ...". Use both rAF and setTimeout to fail even if the timing 36 // of the (unexpected) event isn't as expected. 37 await new Promise((resolve) => { 38 requestAnimationFrame(() => { 39 t.step_timeout(resolve); 40 }); 41 }); 42 }); 43 </script>