unlock.html (1898B)
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 <script type="module"> 9 import { 10 getOppositeOrientation, 11 makeCleanup, 12 attachIframe, 13 } from "./resources/orientation-utils.js"; 14 15 test(() => { 16 screen.orientation.unlock(); 17 }, "unlock() doesn't throw when there is no lock"); 18 19 test(() => { 20 const value = screen.orientation.unlock(); 21 assert_equals(value, undefined); 22 }, "unlock() returns a void value"); 23 24 promise_test(async (t) => { 25 t.add_cleanup(makeCleanup()); 26 await test_driver.bless("request full screen"); 27 await document.documentElement.requestFullscreen(); 28 screen.orientation.unlock(); 29 }, "unlock() doesn't throw when there is no lock with fullscreen"); 30 31 promise_test(async (t) => { 32 t.add_cleanup(makeCleanup()); 33 await test_driver.bless("request full screen"); 34 await document.documentElement.requestFullscreen(); 35 const promise = screen.orientation.lock(getOppositeOrientation()); 36 screen.orientation.unlock(); 37 await promise_rejects_dom(t, "AbortError", promise); 38 }, "unlock() aborts a pending lock request"); 39 40 promise_test(async (t) => { 41 t.add_cleanup(makeCleanup()); 42 const iframe = await attachIframe(); 43 await test_driver.bless("request full screen"); 44 await document.documentElement.requestFullscreen(); 45 const promise = iframe.contentWindow.screen.orientation.lock( 46 getOppositeOrientation() 47 ); 48 screen.orientation.unlock(); 49 await promise_rejects_dom( 50 t, 51 "AbortError", 52 iframe.contentWindow.DOMException, 53 promise 54 ); 55 }, "unlock() aborts a pending lock request across documents"); 56 </script>