dom/tests/mochitest/pointerlock/test_pointerlock-api.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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">
    21         /**
    22          * Pointer Lock tests for bug 633602.  These depend on the fullscreen api
    23          * which doesn't work when run in the mochitests' iframe, since the
    24          * mochitests' iframe doesn't have an allowfullscreen attribute.  To get
    25          * around this, all tests are run in a child window, which can go fullscreen.
    26          * This method is borrowed from content/html/content/test/test_fullscreen-api.html.
    27          **/
    29         SimpleTest.waitForExplicitFinish();
    31         // Ensure the full-screen api is enabled, and will be disabled on test exit.
    32         SpecialPowers.setBoolPref("full-screen-api.enabled", true);
    34         // Disable the requirement for trusted contexts only, so the tests are easier to write.
    35         SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
    37         // Grant "fullscreen" permission on the test domain. This means fullscreen will be
    38         // automatically approved, so pointer lock in the tests will be too.
    39         SpecialPowers.setFullscreenAllowed(document);
    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_approval.html",
    46           "file_screenClientXYConst.html",
    47           "file_childIframe.html",
    48           "file_doubleLock.html",
    49           "file_escapeKey.html",
    50           "file_infiniteMovement.html",
    51           "file_locksvgelement.html",
    52           "file_movementXY.html",
    53           "file_nestedFullScreen.html",
    54           "file_pointerlock-api.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         ];
    65         var gTestWindow = null;
    66         var gTestIndex = 0;
    68         // TODO: if ever we remove these checks for XP and Lion, we should do the same
    69         // in content/html/content/test/test_fullscreen-api.html, which uses the same pattern.
    70         const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
    71         const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1;
    72         const isOSXMtnLion = navigator.userAgent.indexOf("Mac OS X 10.8") != -1;
    73         const isWin8 = navigator.userAgent.indexOf("Windows NT 6.2") != -1;
    75         function finish() {
    76           SpecialPowers.clearUserPref("full-screen-api.enabled");
    77           SpecialPowers.clearUserPref("full-screen-api.allow-trusted-requests-only");
    78           SpecialPowers.removeFullscreenAllowed(document)
    79           SimpleTest.finish();
    80         }
    82         function nextTest() {
    83           if (isWinXP) {
    84             todo(false, "Can't reliably run full-screen tests on Windows XP due to bug 704010");
    85             finish();
    86             return;
    87           }
    88           if (isWin8) {
    89             todo(false, "Can't reliably run full-screen + pointer lock tests on Windows 8");
    90             finish();
    91             return;
    92           }
    93           if (isOSXLion || isOSXMtnLion) {
    94             todo(false, "Can't reliably run full-screen tests on OS X Lion or Mountain Lion, see bug 744125");
    95             finish();
    96             return;
    97           }
    98           if (gTestWindow) {
    99             gTestWindow.close();
   100           }
   101           SimpleTest.waitForFocus(runNextTest);
   102         }
   104         function runNextTest() {
   105           if (gTestIndex < gTestFiles.length) {
   106             gTestWindow = window.open(gTestFiles[gTestIndex], "", "width=500,height=500");
   107             gTestIndex++;
   108           } else {
   109             finish();
   110           }
   111         }
   113         addLoadEvent(nextTest);
   114       </script>
   115     </pre>
   116   </body>
   117 </html>

mercurial