Bug 1148219 - Improve reliability of the test_scroll_snapping.html mochitest. r=roc, a=test-only
authorKearwood (Kip) Gilbert <kgilbert@mozilla.com>
Mon, 06 Apr 2015 13:32:00 +0200
changeset 266950 7f5a0e2cdb00c6f3cea0968e053118e7a58de258
parent 266949 88dea0896169196e5fe9dd425798b2460180f1ab
child 266951 a6f8ea1578689e91b7f6ff5ab02b5800b3bc92a9
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, test-only
bugs1148219
milestone39.0a2
Bug 1148219 - Improve reliability of the test_scroll_snapping.html mochitest. r=roc, a=test-only - The test_scroll_snapping.html mochitest now waits up to 30 frames for scrolling to start before giving up and reporting a failure.
layout/base/tests/test_scroll_snapping_scrollbars.html
--- a/layout/base/tests/test_scroll_snapping_scrollbars.html
+++ b/layout/base/tests/test_scroll_snapping_scrollbars.html
@@ -228,16 +228,17 @@ var testCases = [
 
 var step = 0;
 var sc; // Scroll Container
 var sd; // Scrolled Div
 
 var lastScrollTop;
 var lastScrollLeft;
 var stopFrameCount;
+var winUtils = SpecialPowers.DOMWindowUtils;
 
 function doTest() {
   var testCase = testCases[step];
 
   stopFrameCount = 0;
   lastScrollTop = sc.scrollTop;
   lastScrollLeft = sc.scrollLeft;
 
@@ -250,31 +251,48 @@ function doTest() {
                   testCase.mousePosition.y,
                   { type: "mousedown" });
 
   synthesizeMouse(sc,
                   testCase.mousePosition.x + testCase.mouseOffset.x,
                   testCase.mousePosition.y + testCase.mouseOffset.y,
                   { type: "mousemove" });
 
-  window.requestAnimationFrame(function() {
-    isnot("(" + sc.scrollLeft + "," + sc.scrollTop + ")",
-          "(" + testCase.startScroll.x +"," + testCase.startScroll.y + ")",
-          "Step " + step + ": Synthesized mouse events move scroll position. ("
-            + testCase.description + ")");
+  stopFrameCount = 0;
+  waitForScrollStart();
+}
+
+function waitForScrollStart() {
+  // Wait for up to 30 frames for scrolling to start
+  var testCase = testCases[step];
+  if (testCase.startScroll.y != sc.scrollTop
+      || testCase.startScroll.x != sc.scrollLeft
+      || ++stopFrameCount < 30) {
+    window.requestAnimationFrame(doMouseUp);
+  } else {
+    window.requestAnimationFrame(waitForScrollStart);
+  }
+}
 
-    window.setTimeout(function() {
-      synthesizeMouse(sc,
-                      testCase.mousePosition.x + testCase.mouseOffset.x,
-                      testCase.mousePosition.y + testCase.mouseOffset.y,
-                      { type: "mouseup" });
+function doMouseUp() {
+  var testCase = testCases[step];
+  isnot("(" + sc.scrollLeft + "," + sc.scrollTop + ")",
+        "(" + testCase.startScroll.x +"," + testCase.startScroll.y + ")",
+        "Step " + step + ": Synthesized mouse events move scroll position. ("
+          + testCase.description + ")");
 
-      window.requestAnimationFrame(waitForScrollStop);
-    }, testCase.duration);
-  });
+  window.setTimeout(function() {
+    synthesizeMouse(sc,
+                    testCase.mousePosition.x + testCase.mouseOffset.x,
+                    testCase.mousePosition.y + testCase.mouseOffset.y,
+                    { type: "mouseup" });
+
+    stopFrameCount = 0;
+    window.requestAnimationFrame(waitForScrollStop);
+  }, testCase.duration);
 }
 
 function waitForScrollStop() {
   if (stopFrameCount > 30) {
     // We have the same position for 30 consecutive frames -- we are stopped
     verifyTest();
   } else {
     // Still moving