tor-browser

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

hidden_document.html (2819B)


      1 <!DOCTYPE html>
      2 <meta name="timeout" content="long" />
      3 <title>
      4  Prevent hidden documents from locking orientation
      5 </title>
      6 <link rel="help" href="https://github.com/w3c/screen-orientation/pull/232" />
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <script src="/resources/testdriver.js"></script>
     10 <script src="/resources/testdriver-vendor.js"></script>
     11 <script src="/page-visibility/resources/window_state_context.js"></script>
     12 <script type="module">
     13  import { makeCleanup, getOppositeOrientation } from "./resources/orientation-utils.js";
     14 
     15  promise_test(async (t) => {
     16    const { minimize, restore } = window_state_context(t);
     17    t.add_cleanup(restore);
     18 
     19    await minimize();
     20 
     21    assert_equals(document.visibilityState, "hidden", "Document must be hidden");
     22    await promise_rejects_dom(t, "SecurityError", screen.orientation.lock(getOppositeOrientation()));
     23  }, "hidden documents must reject went trying to call lock or unlock");
     24 
     25  promise_test(async (t) => {
     26    const { minimize, restore } = window_state_context(t);
     27    t.add_cleanup(restore);
     28 
     29    await minimize();
     30 
     31    assert_equals(document.visibilityState, "hidden", "Document must be hidden");
     32    assert_throws_dom("SecurityError", () => screen.orientation.unlock());
     33  }, "hidden documents must reject went trying to call unlock");
     34 
     35  promise_test(async (t) => {
     36    const { minimize, restore } = window_state_context(t);
     37    t.add_cleanup(makeCleanup());
     38 
     39    await test_driver.bless("request full screen");
     40    await document.documentElement.requestFullscreen();
     41    await screen.orientation.lock(getOppositeOrientation());
     42 
     43    await minimize();
     44 
     45    assert_equals(document.visibilityState, "hidden", "Document must be hidden");
     46    assert_throws_dom("SecurityError", () => screen.orientation.unlock());
     47  }, "hidden documents must not unlock the screen orientation");
     48 
     49  promise_test(async (t) => {
     50    const { minimize, restore } = window_state_context(t);
     51    t.add_cleanup(makeCleanup());
     52    await test_driver.bless("request full screen");
     53    await document.documentElement.requestFullscreen();
     54    await screen.orientation.lock(getOppositeOrientation());
     55 
     56    await minimize();
     57 
     58    assert_equals(document.visibilityState, "hidden");
     59    await promise_rejects_dom(t, "SecurityError", screen.orientation.lock(getOppositeOrientation()));
     60 
     61    // Maximize, now everything should work as expected.
     62    await restore();
     63 
     64    assert_equals(document.visibilityState, "visible");
     65 
     66    await test_driver.bless("request full screen");
     67    await document.documentElement.requestFullscreen();
     68    await screen.orientation.lock(getOppositeOrientation());
     69    screen.orientation.unlock();
     70  }, "Once maximized, a minimized window can lock or unlock the screen orientation again");
     71 </script>