active-lock.html (2377B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <meta viewport="width=device-width, initial-scale=1" /> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testdriver.js"></script> 7 <script src="/resources/testdriver-vendor.js"></script> 8 <body> 9 <p id="fragment"></p> 10 <a href="#fragment">fragment</a> 11 </body> 12 <script type="module"> 13 import { 14 attachIframe, 15 getOppositeOrientation, 16 makeCleanup, 17 } from "./resources/orientation-utils.js"; 18 19 promise_test(async (t) => { 20 t.add_cleanup(makeCleanup()); 21 await test_driver.bless("request full screen"); 22 await document.documentElement.requestFullscreen(); 23 const orientation = getOppositeOrientation(); 24 const p = screen.orientation.lock("landscape"); 25 await test_driver.click(document.querySelector("a")); 26 await p; 27 }, "Performing a fragment navigation must not abort the screen orientation change"); 28 29 promise_test(async (t) => { 30 const iframe = await attachIframe({ src: "./resources/nav_iframe.html" }); 31 t.add_cleanup(makeCleanup({ iframe })); 32 await test_driver.bless("request full screen", null, iframe.contentWindow); 33 await iframe.contentDocument.documentElement.requestFullscreen(); 34 const orientation = getOppositeOrientation(); 35 const p = iframe.contentWindow.screen.orientation.lock(orientation); 36 const anchor = iframe.contentDocument.querySelector("#clickme"); 37 await test_driver.click(anchor); 38 await p; 39 }, "Performing a fragment navigation within an iframe must not abort the lock promise"); 40 41 promise_test(async (t) => { 42 const iframe = await attachIframe(); 43 t.add_cleanup(makeCleanup({ iframe })); 44 await test_driver.bless("request full screen", null, iframe.contentWindow); 45 await iframe.contentDocument.documentElement.requestFullscreen(); 46 const orientation = getOppositeOrientation(); 47 const lockPromise = iframe.contentWindow.screen.orientation.lock(orientation); 48 const frameDOMException = iframe.contentWindow.DOMException; 49 await new Promise((r) => { 50 iframe.addEventListener("load", r, { once: true }); 51 iframe.contentWindow.location.href = "about:blank"; 52 }); 53 await promise_rejects_dom(t, "AbortError", frameDOMException, lockPromise); 54 }, "Unloading an iframe by navigating it must abort the lock promise"); 55 </script>