tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

lock-unlock-check.html (1758B)


      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    attachIframe,
     11    getOppositeOrientation,
     12    makeCleanup,
     13  } from "./resources/orientation-utils.js";
     14 
     15  promise_test(async (t) => {
     16    t.add_cleanup(makeCleanup());
     17    await test_driver.bless("request full screen");
     18    await document.documentElement.requestFullscreen();
     19 
     20    const eventPromise = new Promise((res, rej) => {
     21      screen.orientation.addEventListener(
     22        "change",
     23        () => {
     24          screen.orientation
     25            .lock(getOppositeOrientation())
     26            .then(res)
     27            .catch(rej);
     28        },
     29        { once: true }
     30      );
     31    });
     32    const lockPromise = screen.orientation.lock(getOppositeOrientation());
     33    await Promise.all([eventPromise, lockPromise]);
     34  }, "Re-locking the screen orientation after a change event fires must not abort");
     35 
     36  promise_test(async (t) => {
     37    t.add_cleanup(makeCleanup());
     38    await test_driver.bless("request full screen");
     39    await document.documentElement.requestFullscreen();
     40    const eventPromise = new Promise((res) => {
     41      screen.orientation.addEventListener(
     42        "change",
     43        () => {
     44          screen.orientation.unlock();
     45          res();
     46        },
     47        { once: true }
     48      );
     49    });
     50    const lockPromise = screen.orientation.lock(getOppositeOrientation());
     51    await Promise.all([eventPromise, lockPromise]);
     52  }, "Unlocking the screen orientation after a change event must not abort");
     53 </script>