Bug 1357082 - Retry synthesizeMouseAtCenter until it is performed. r=xidorn
authorGreg Mierzwinski <gmierz2@outlook.com>
Tue, 06 Jun 2017 09:22:36 -0400
changeset 411157 f8d48ac82e7b06c803558ff5086882f2e122783a
parent 411156 58a93f7d6b20b5809ed14294eabccd825aeb174f
child 411158 d2fe4dfffa0da867b7f1d3ef1c0174b261789811
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1357082
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1357082 - Retry synthesizeMouseAtCenter until it is performed. r=xidorn This patch is for the intermittent bug 1357082 which has a failure in the test 'test_pointerlock-api.html' and is more frequent when it is run on Ubuntu 16.04. This failure is resolved by retrying the mouse movement until it actually occurs. MozReview-Commit-ID: 9XC4zmWj8Gn
dom/tests/mochitest/pointerlock/file_infiniteMovement.html
dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html
--- a/dom/tests/mochitest/pointerlock/file_infiniteMovement.html
+++ b/dom/tests/mochitest/pointerlock/file_infiniteMovement.html
@@ -32,40 +32,47 @@ https://bugzilla.mozilla.org/show_bug.cg
          */
 
         SimpleTest.waitForExplicitFinish();
 
         var div = document.getElementById("div")
           , divCenterWidth = 0
           , divCenterHeight = 0
           , totalMovementX = 0
-          , totalMovementY = 0;
+          , totalMovementY = 0
+          , mouseMoveIntervalID;
 
         function runTests () {
           ok(totalMovementX > div.getBoundingClientRect().width,
                "Should have moved more than one screen's worth in width." +
                "TotalX: " + totalMovementX + " Screensize X: " + div.getBoundingClientRect().width);
           ok(totalMovementY > div.getBoundingClientRect().height,
              "Should have moved more than one screen's worth in height." +
              "TotalY: " + totalMovementY + " Screensize Y: " + div.getBoundingClientRect().height);
         }
 
         var firstMoveListener = function (e) {
           info("Got first mousemove");
+          clearInterval(mouseMoveIntervalID);
           div.removeEventListener("mousemove", firstMoveListener);
           div.addEventListener("mousemove", secondMoveListener);
 
-          synthesizeMouse(div,(divCenterWidth/2) * 3,
-            (divCenterHeight/2) * 3, {
-            type: "mousemove"
-          }, window);
+          // Bug 1357082
+          // Retrigger synthesizeMouse until it actually happens.
+          mouseMoveIntervalID = setInterval(() => {
+            synthesizeMouse(div,(divCenterWidth/2) * 3,
+              (divCenterHeight/2) * 3, {
+              type: "mousemove"
+            }, window);
+          }, 100);
         }
 
         var secondMoveListener = function (e) {
           info("Got second mousemove");
+          clearInterval(mouseMoveIntervalID);
           totalMovementX = divCenterWidth + ((divCenterWidth / 2) * 3);
           totalMovementY = divCenterHeight + ((divCenterHeight / 2) * 3);
 
           div.removeEventListener("mousemove", secondMoveListener);
           addFullscreenChangeContinuation("exit", function() {
             info("Got fullscreenchange for exiting");
             runTests();
             SimpleTest.finish();
@@ -76,19 +83,23 @@ https://bugzilla.mozilla.org/show_bug.cg
         document.addEventListener("pointerlockchange", function (e) {
           if (document.pointerLockElement === div) {
             info("Got pointerlockchange for entering");
             div.addEventListener("mousemove", firstMoveListener);
 
             divCenterWidth = Math.round(div.getBoundingClientRect().width / 2);
             divCenterHeight = Math.round(div.getBoundingClientRect().height / 2);
 
-            synthesizeMouse(div, divCenterWidth, divCenterHeight, {
-              type: "mousemove"
-            }, window);
+            // Bug 1357082
+            // Retrigger synthesizeMouse until it actually happens.
+            mouseMoveIntervalID = setInterval(() => {
+              synthesizeMouse(div, divCenterWidth, divCenterHeight, {
+                type: "mousemove"
+              }, window);
+            }, 100);
           } else {
             info("Got pointerlockchange for exiting");
           }
         });
 
         function start() {
           info("Requesting fullscreen on parent");
           addFullscreenChangeContinuation("enter", function() {
--- a/dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html
+++ b/dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html
@@ -37,17 +37,18 @@ https://bugzilla.mozilla.org/show_bug.cg
         this.mouseClick = false;
         this.mouseScroll = false;
         this.wheel = false;
       }
 
       var parent = document.getElementById("parent")
         , child = document.getElementById("child")
         , parentStats = new MouseEventStats()
-        , childStats = new MouseEventStats();
+        , childStats = new MouseEventStats()
+        , mouseMoveIntervalID;
 
       function runTests () {
         is(childStats.mouseMove, false, "Child shound not receive mousemove event.");
         is(childStats.mouseDown, false, "Child should not receive mousedown event.");
         is(childStats.mouseUp, false, "Child should not receive mouseup event.");
         is(childStats.mouseClick, false, "Child should not receive click event.");
         is(childStats.mouseScroll, false, "Child should not receive DOMMouseScroll event.");
         is(childStats.wheel, false, "Child should not receive wheel event.");
@@ -63,16 +64,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
       /**
        * The event listeners for the child element shouldn't be fired
        * Mouse events will only happen when the pointer is locked
        * and if the pointer is locked all the mouse events should be
        * retargetted to the locked element
        **/
       var childMoveTest = function() {
+        clearInterval(mouseMoveIntervalID);
         childStats.mouseMove = true;
       }
 
       var childDownTest = function() {
         childStats.mouseDown = true;
       };
 
       var childUpTest = function() {
@@ -89,16 +91,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
       var childWheelTest = function() {
         childStats.wheel = true;
       };
 
       //  Event listeners for the parent element
       var startMouseTests = function() {
         info("Got parent mousemove");
+        clearInterval(mouseMoveIntervalID);
         parent.removeEventListener("mousemove", startMouseTests);
         parent.addEventListener("DOMMouseScroll", parentScrollTest);
         child.addEventListener("DOMMouseScroll", childScrollTest);
         SimpleTest.executeSoon(function () {
           synthesizeWheel(child, 5, 5, {'deltaY': 10, 'lineOrPageDeltaY': 10,
                                         'deltaMode': WheelEvent.DOM_DELTA_LINE});
         });
       };
@@ -180,19 +183,21 @@ https://bugzilla.mozilla.org/show_bug.cg
         });
       }
 
       document.addEventListener("pointerlockchange", function (e) {
         if (document.pointerLockElement === parent) {
           info("Got pointerlockchange for entering");
           parent.addEventListener("mousemove", startMouseTests);
           child.addEventListener("mousemove", childMoveTest);
-          SimpleTest.executeSoon(function () {
+          // Bug 1357082
+          // Retrigger synthesizeMouseAtCenter until it actually happens.
+          mouseMoveIntervalID = setInterval(() => {
             synthesizeMouseAtCenter(parent, {type: "mousemove"}, window);
-          });
+          }, 100);
         } else {
           info("Got pointerlockchange for exiting");
         }
       });
 
       function start() {
         info("Requesting fullscreen on parent");
         addFullscreenChangeContinuation("enter", function() {