Bug 1180351 - Enable pointerlock tests on Windows and Linux. draft
authorXidorn Quan <quanxunzhen@gmail.com>
Mon, 19 Oct 2015 22:25:57 +1100
changeset 317999 66ad8399cea20f73e884c2a718fe154268df24e8
parent 317993 54f1ffc83b797305843934764fecf799c6cfc8b1
child 512396 f95b622820a996f53840136db0433e122bd71cc8
push id8804
push userxquan@mozilla.com
push dateWed, 30 Dec 2015 04:50:31 +0000
bugs1180351
milestone46.0a1
Bug 1180351 - Enable pointerlock tests on Windows and Linux.
dom/tests/mochitest/pointerlock/file_allowPointerLockSandboxFlag.html
dom/tests/mochitest/pointerlock/file_nestedFullScreen.html
dom/tests/mochitest/pointerlock/file_screenClientXYConst.html
dom/tests/mochitest/pointerlock/mochitest.ini
dom/tests/mochitest/pointerlock/test_pointerlock-api.html
--- a/dom/tests/mochitest/pointerlock/file_allowPointerLockSandboxFlag.html
+++ b/dom/tests/mochitest/pointerlock/file_allowPointerLockSandboxFlag.html
@@ -27,17 +27,17 @@
       <script type="application/javascript">
         /*
          * Test for Bug 784402
          * Test allow-pointer-lock sandbox flag.
          */
 
         SimpleTest.waitForExplicitFinish(1);
 
-        var iframe
+        var iframe = document.getElementById("iframe")
           , iframeDiv
           , contentDocument
           , pointerLocked = 0
           , numberOfRuns = 0;
 
         function runTests () {
           is(pointerLocked, 1, "Pointer should only have been locked once. " +
             "Without allow-pointer-lock flag, a sandboxed document should not be " +
@@ -50,39 +50,44 @@
 
           // remove allow-pointer-lock sandbox flag
           iframe.setAttribute("sandbox", "allow-scripts allow-same-origin");
           // reloads the iframe, startTest function gets called again
           iframe.setAttribute("src", "iframe_differentDOM.html");
         }
 
         function startTest () {
-          iframe = document.getElementById("iframe");
+          SimpleTest.waitForFocus(doStartTest, iframe.contentWindow);
+        }
+        function doStartTest() {
           contentDocument = iframe.contentDocument;
           iframeDiv = contentDocument.getElementById("div");
 
           numberOfRuns++;
 
           contentDocument.addEventListener("mozpointerlockchange", function () {
             if (contentDocument.mozPointerLockElement === iframeDiv) {
               pointerLocked++;
-              resetIframe();
+              contentDocument.mozCancelFullScreen();
             }
           });
 
           contentDocument.addEventListener("mozpointerlockerror", function () {
             contentDocument.mozCancelFullScreen();
           });
 
           contentDocument.addEventListener("mozfullscreenchange", function () {
-            if (contentDocument.mozFullScreen &&
-              contentDocument.mozFullScreenElement === iframeDiv) {
+            if (contentDocument.mozFullScreen) {
+              ok(contentDocument.mozFullScreenElement === iframeDiv,
+                 "Fullscreen element can only be iframe div");
               // during second run iframe won't have allow-pointer-lock flag and
               // mozRequestPointerLock will fail, mozpointerlockerror should be fired
               iframeDiv.mozRequestPointerLock();
+            } else if (numberOfRuns === 1) {
+              resetIframe();
             } else if (numberOfRuns === 2) {
               runTests();
             }
           });
 
         iframeDiv.mozRequestFullScreen();
       }
       </script>
--- a/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html
+++ b/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html
@@ -52,19 +52,20 @@
           childDiv.mozRequestFullScreen();
         }
       }, false);
 
       document.addEventListener("mozfullscreenchange", function() {
         if (document.mozFullScreenElement === parentDiv) {
           if (parentDivFullScreen === true) {
             document.mozCancelFullScreen();
+          } else {
+            parentDivFullScreen = true;
+            parentDiv.mozRequestPointerLock();
           }
-          parentDivFullScreen = true;
-          parentDiv.mozRequestPointerLock();
         }
         else if (document.mozFullScreenElement === childDiv) {
           pointerLocked = !!document.mozPointerLockElement;
           document.mozCancelFullScreen();
         }
         else {
           runTests();
           SimpleTest.finish();
--- a/dom/tests/mochitest/pointerlock/file_screenClientXYConst.html
+++ b/dom/tests/mochitest/pointerlock/file_screenClientXYConst.html
@@ -19,16 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript">
       /*
        * Test for Bug 633602
        * Confirm that screenX/Y and clientX/Y are constants when the pointer
        * is locked.
        */
 
       SimpleTest.waitForExplicitFinish();
+      SimpleTest.requestFlakyTimeout("We may need to wait for window's moving");
 
       var div
         , divRect
         , unLockedCoords
         , lockedCoords
         , isUnlocked = false
         , isLocked = false;
 
--- a/dom/tests/mochitest/pointerlock/mochitest.ini
+++ b/dom/tests/mochitest/pointerlock/mochitest.ini
@@ -16,9 +16,9 @@ support-files =
   file_targetOutOfFocus.html
   file_screenClientXYConst.html
   file_suppressSomeMouseEvents.html
   file_locksvgelement.html
   file_allowPointerLockSandboxFlag.html
   iframe_differentDOM.html
 
 [test_pointerlock-api.html]
-skip-if = buildapp == 'b2g' || toolkit == 'android' || os == 'linux' || os == 'win' # B2G - window.open focus issues using fullscreen. (For Linux & Win) Bug1180351
+skip-if = buildapp == 'b2g' || toolkit == 'android' # B2G - window.open focus issues using fullscreen.
--- a/dom/tests/mochitest/pointerlock/test_pointerlock-api.html
+++ b/dom/tests/mochitest/pointerlock/test_pointerlock-api.html
@@ -22,16 +22,17 @@ https://bugzilla.mozilla.org/show_bug.cg
          * Pointer Lock tests for bug 633602.  These depend on the fullscreen api
          * which doesn't work when run in the mochitests' iframe, since the
          * mochitests' iframe doesn't have an allowfullscreen attribute.  To get
          * around this, all tests are run in a child window, which can go fullscreen.
          * This method is borrowed from dom/html/test/test_fullscreen-api.html.
          **/
 
         SimpleTest.waitForExplicitFinish();
+        SimpleTest.requestCompleteLog();
 
         SpecialPowers.pushPrefEnv({"set": [
           ["full-screen-api.enabled", true],
           ["full-screen-api.allow-trusted-requests-only", false],
           ["full-screen-api.transition-duration.enter", "0 0"],
           ["full-screen-api.transition-duration.leave", "0 0"]
         ]}, nextTest);
 
@@ -55,18 +56,18 @@ https://bugzilla.mozilla.org/show_bug.cg
           "file_suppressSomeMouseEvents.html",
           "file_targetOutOfFocus.html",
           "file_withoutDOM.html",
           "file_allowPointerLockSandboxFlag.html"
         ];
 
         var gDisableList = [
           // Bug 1174323
-          { file: "file_screenClientXYConst.html",
-            platform: "MacIntel" }
+          { file: "file_screenClientXYConst.html", platform: "MacIntel" },
+          { file: "file_screenClientXYConst.html", platform: "Win64" },
         ];
 
         var gTestWindow = null;
         var gTestIndex = 0;
 
         function nextTest() {
           if (gTestWindow) {
             gTestWindow.close();