Bug 1258896 - Make the scroll position check in test_mousecapture a little fuzzier to allow for scroll event coalescing. r=Gijs a=test-only
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 05 May 2016 12:28:09 -0400
changeset 332842 fca62ad9c45ca847ac004a2b16807a63763e5c29
parent 332841 901b6248af7d34012dc519cef40ec38c034f1c39
child 332843 20fb337ac107d7a62fd0bff7ad4148c87cd1f9f6
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, test-only
bugs1258896
milestone48.0a2
Bug 1258896 - Make the scroll position check in test_mousecapture a little fuzzier to allow for scroll event coalescing. r=Gijs a=test-only MozReview-Commit-ID: LdmaJHeb7rl
toolkit/content/tests/mochitest/test_mousecapture.xhtml
--- a/toolkit/content/tests/mochitest/test_mousecapture.xhtml
+++ b/toolkit/content/tests/mochitest/test_mousecapture.xhtml
@@ -71,20 +71,26 @@ function selectionScrollCheck()
     if (count++ < 6)
       return;
 
     otherWindow.removeEventListener("scroll", selectionScrollDone, false);
 
     var selectedText = otherWindow.getSelection().toString().replace(/\r/g, "");
     is(selectedText, "One\n\nTwo", "text is selected");
 
-    // should have scrolled 20 pixels from the mousemove above and six extra
-    // times from the selection scroll timer for a total of 140
-    var oldScrollY = otherWindow.scrollY;
-    is(otherWindow.scrollY, 140, "selection scroll position after timer");
+    // should have scrolled 20 pixels from the mousemove above and at least 6
+    // extra 20-pixel increments from the selection scroll timer. "At least 6"
+    // because we waited for 6 scroll events but multiple scrolls could get
+    // coalesced into a single scroll event. Therefore we allow 6-15 scrolls,
+    // which corresponds to a scroll position of 140 to 320. The 15 is chosen
+    // arbitrarily and can be adjusted.
+    var scrollY = otherWindow.scrollY;
+    ok(scrollY >= 140, "selection scroll position after timer is at least 140");
+    ok(scrollY <= 320, "selection scroll position after timer is not more than 320");
+    ok((scrollY % 20) == 0, "selection scroll position after timer is multiple of 20");
 
     synthesizeMouse(element, 4, otherWindow.innerHeight + 25, { type: "mouseup" }, otherWindow);
     disableNonTestMouseEvents(false);
     otherWindow.close();
 
     if (loadInWindow) {
       SimpleTest.finish();
     }