tor-browser

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

test_lock_orientation_after_fullscreen.html (2298B)


      1 <!DOCTYPE html>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1757431
      5 -->
      6 <head>
      7 <title>Test for Bug 1757431</title>
      8 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1757431">Mozilla Bug 1757431</a>
     13 <div id="fullscreen">fullscreen</div>
     14 <script>
     15 add_task(async () => {
     16  await SpecialPowers.pushPrefEnv({
     17    set: [["dom.screenorientation.allow-lock", true]]
     18  });
     19 
     20  const element = document.getElementById("fullscreen");
     21  await SpecialPowers.wrap(element).requestFullscreen();
     22  let newOrientationLock = SpecialPowers.getDOMWindowUtils(window).orientationLock;
     23 
     24  ok(document.fullscreen, "Document should be in fullscreen");
     25  is(newOrientationLock, 0, "Orientation lock in browsing context should be none by enterFullscreen");
     26 
     27  const originalOrientationType = window.screen.orientation.type;
     28  const newOrientationType = originalOrientationType.startsWith("landscape") ? "portrait-primary" : "landscape-primary";
     29 
     30  await window.screen.orientation.lock(newOrientationType);
     31  newOrientationLock = SpecialPowers.getDOMWindowUtils(window).orientationLock;
     32  if (newOrientationType == "portrait-primary") {
     33    is(newOrientationLock, 1, "Orientation lock in browsing context should be portrait-primary");
     34  } else {
     35    is(newOrientationLock, 4, "Orientation lock in browsing context should be landscape-primary");
     36  }
     37 
     38  await window.screen.orientation.lock(originalOrientationType);
     39  newOrientationLock = SpecialPowers.getDOMWindowUtils(window).orientationLock;
     40  if (originalOrientationType == "portrait-primary") {
     41    is(newOrientationLock, 1, "Orientation lock in browsing context should be portrait-primary");
     42  } else {
     43    is(newOrientationLock, 4, "Orientation lock in browsing context should be landscape-primary");
     44  }
     45 
     46  await document.exitFullscreen();
     47 
     48  // Wait fullscreen change in ScreenOrientation
     49  await new Promise(r =>
     50    window.requestAnimationFrame(() => window.requestAnimationFrame(r))
     51  );
     52 
     53  newOrientationLock = SpecialPowers.getDOMWindowUtils(window).orientationLock;
     54  is(newOrientationLock, 0, "Orientation lock in browsing context should be none by exitFullscreen");
     55 });
     56 </script>
     57 </body>
     58 </html>