tor-browser

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

test_pointerlock-api.html (3964B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602
      5 -->
      6  <head>
      7    <title>Test for Bug 633602</title>
      8    <script type="application/javascript"  src="/tests/SimpleTest/SimpleTest.js"></script>
      9    <script type="application/javascript"  src="/tests/SimpleTest/EventUtils.js"></script>
     10    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11  </head>
     12  <body>
     13    <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
     14      Mozilla Bug 633602
     15    </a>
     16    <div id="content">
     17    </div>
     18    <pre id="test">
     19      <script type="application/javascript">
     20        const { AppConstants } = SpecialPowers.ChromeUtils.importESModule(
     21          "resource://gre/modules/AppConstants.sys.mjs"
     22        );
     23 
     24        /**
     25         * Pointer Lock tests for bug 633602.  These depend on the fullscreen api
     26         * which doesn't work when run in the mochitests' iframe, since the
     27         * mochitests' iframe doesn't have an allowfullscreen attribute.  To get
     28         * around this, all tests are run in a child window, which can go fullscreen.
     29         * This method is borrowed from dom/html/test/test_fullscreen-api.html.
     30         */
     31 
     32        SimpleTest.waitForExplicitFinish();
     33 
     34        SpecialPowers.pushPrefEnv({"set": [
     35          ["full-screen-api.enabled", true],
     36          ["full-screen-api.allow-trusted-requests-only", false],
     37          ["full-screen-api.transition-duration.enter", "0 0"],
     38          ["full-screen-api.transition-duration.leave", "0 0"]
     39        ]}, nextTest);
     40 
     41        // Run the tests which go full-screen in new window, as Mochitests
     42        // normally run in an iframe, which by default will not have the
     43        // allowfullscreen attribute set, so full-screen won't work.
     44        var gTestFiles = [
     45          "file_screenClientXYConst.html",
     46          "file_childIframe.html",
     47          "file_doubleLock.html",
     48          "file_escapeKey.html",
     49          "file_infiniteMovement.html",
     50          "file_locksvgelement.html",
     51          "file_movementXY.html",
     52          "file_nestedFullScreen.html",
     53          "file_pointerlock-api.html",
     54          "file_pointerlock-api-with-shadow.html",
     55          "file_pointerlockerror.html",
     56          "file_pointerLockPref.html",
     57          "file_removedFromDOM.html",
     58          "file_retargetMouseEvents.html",
     59          "file_suppressSomeMouseEvents.html",
     60          "file_targetOutOfFocus.html",
     61          "file_withoutDOM.html",
     62          "file_allowPointerLockSandboxFlag.html",
     63          "file_changeLockElement.html",
     64        ];
     65 
     66        var gDisableList = [ 
     67          // Bug 1615802
     68          { file: "file_screenClientXYConst.html", platform: "macosx" },
     69          // Bug 1357082
     70          { file: "file_retargetMouseEvents.html", platform: "all" },
     71        ];
     72 
     73        var gTestWindow = null;
     74        var gTestIndex = 0;
     75 
     76        function nextTest() {
     77          if (gTestWindow) {
     78            gTestWindow.close();
     79          }
     80 
     81          // Try to stabilize the state before running the next test.
     82          SimpleTest.waitForFocus(
     83            () => requestAnimationFrame(() => setTimeout(runNextTest)));
     84        }
     85 
     86        function runNextTest() {
     87          if (gTestIndex < gTestFiles.length) {
     88            var file = gTestFiles[gTestIndex];
     89            gTestIndex++;
     90 
     91            var skipTest = false;
     92            for (var item of gDisableList) {
     93              if (item.file == file &&
     94                  ("all" == item.platform || AppConstants.platform == item.platform)) {
     95                skipTest = true;
     96                break;
     97              }
     98            }
     99            if (!skipTest) {
    100              info(`Testing ${file}`);
    101              gTestWindow = window.open(file, "", "width=500,height=500");
    102            } else {
    103              info(`Skip ${file}`);
    104              nextTest();
    105            }
    106          } else {
    107            SimpleTest.finish();
    108          }
    109        }
    110      </script>
    111    </pre>
    112  </body>
    113 </html>