Bug 1276107 - Move scrollWheelOver() into apz_test_native_event_utils.js, renaming it to moveMouseAndScrollWheelOver(). r=kats
☠☠ backed out by 7093be1d222f ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Wed, 01 Jun 2016 19:39:20 -0400
changeset 339242 a09ad974b522416a6ef787463511797a69272033
parent 339241 8df1bde7eafd146bf431f50340d0fe277426d65a
child 339243 8e6211a8cc26d964f0dd069e01ebc61ef23c7b45
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1276107
milestone49.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 1276107 - Move scrollWheelOver() into apz_test_native_event_utils.js, renaming it to moveMouseAndScrollWheelOver(). r=kats MozReview-Commit-ID: JgJIZm783qK
gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
gfx/layers/apz/test/mochitest/helper_scroll_on_position_fixed.html
--- a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
@@ -236,8 +236,28 @@ function synthesizeNativeMouseEvent(aEle
 function synthesizeNativeClick(aElement, aX, aY, aObserver = null) {
   var pt = coordinatesRelativeToScreen(aX, aY, aElement);
   var utils = SpecialPowers.getDOMWindowUtils(aElement.ownerDocument.defaultView);
   utils.sendNativeMouseEvent(pt.x, pt.y, nativeMouseDownEventMsg(), 0, aElement, function() {
     utils.sendNativeMouseEvent(pt.x, pt.y, nativeMouseUpEventMsg(), 0, aElement, aObserver);
   });
   return true;
 }
+
+// Move the mouse to (dx, dy) relative to |element|, and scroll the wheel
+// at that location.
+// Moving the mouse is necessary to avoid wheel events from two consecutive
+// scrollWheelOver() calls on different elements being incorreclty considered
+// as part of t he same wheel transaction.
+// We also wait for the mouse move event to be processed before sending the
+// wheel event, otherwise there is a chance they might get reordered, and
+// we have the transaction problem again.
+// XXX FOOTGUN: On Windows, if the mouse cursor is already at the target
+//              position, the mouse-move event doesn't get dispatched, and
+//              we end up hanging waiting for it. As a result, care must
+//              be taken that the mouse isn't already at the target position
+//              when using this function.
+function moveMouseAndScrollWheelOver(element, dx, dy, testDriver) {
+  return synthesizeNativeMouseMoveAndWaitForMoveEvent(element, dx, dy, function() {
+    synthesizeNativeWheelAndWaitForScrollEvent(element, dx, dy, 0, -10, testDriver);
+  });
+}
+
--- a/gfx/layers/apz/test/mochitest/helper_scroll_on_position_fixed.html
+++ b/gfx/layers/apz/test/mochitest/helper_scroll_on_position_fixed.html
@@ -1,68 +1,54 @@
 <head>
   <meta name="viewport" content="width=device-width; initial-scale=1.0">
   <title>Wheel-scrolling over position:fixed and position:sticky elements, in the top-level document as well as iframes</title>
   <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
   <script type="application/javascript" src="apz_test_utils.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
   <script type="application/javascript">
 
-// Scroll the mouse wheel at (dx, dy) relative to |element|.
-function scrollWheelOver(element, dx, dy, testDriver) {
-  // Move the mouse to the desired wheel location.
-  // Not doing so can result in the wheel events from two consecutive
-  // scrollWheelOver() calls on different elements being incorrectly considered
-  // as part of the same wheel transaction.
-  // We also wait for the mouse move event to be processed before sending the
-  // wheel event, otherwise there is a chance they might get reordered, and
-  // we have the transaction problem again.
-  return synthesizeNativeMouseMoveAndWaitForMoveEvent(element, dx, dy, function() {
-    synthesizeNativeWheelAndWaitForScrollEvent(element, dx, dy, 0, -10, testDriver);
-  });
-}
-
 function* test(testDriver) {
   var iframeWin = document.getElementById('iframe').contentWindow;
 
   // scroll over the middle of the iframe's position:sticky element, check
   // that it scrolls the iframe
   var scrollPos = iframeWin.scrollY;
-  yield scrollWheelOver(iframeWin.document.body, 50, 150, testDriver);
+  yield moveMouseAndScrollWheelOver(iframeWin.document.body, 50, 150, testDriver);
   ok(iframeWin.scrollY > scrollPos, "iframe scrolled after wheeling over the position:sticky element");
 
   // same, but using the iframe's position:fixed element
   scrollPos = iframeWin.scrollY;
-  yield scrollWheelOver(iframeWin.document.body, 250, 150, testDriver);
+  yield moveMouseAndScrollWheelOver(iframeWin.document.body, 250, 150, testDriver);
   ok(iframeWin.scrollY > scrollPos, "iframe scrolled after wheeling over the position:fixed element");
 
   // same, but scrolling the scrollable frame *inside* the position:fixed item
   var fpos = document.getElementById('fpos_scrollable');
   scrollPos = fpos.scrollTop;
-  yield scrollWheelOver(fpos, 50, 150, testDriver);
+  yield moveMouseAndScrollWheelOver(fpos, 50, 150, testDriver);
   ok(fpos.scrollTop > scrollPos, "scrollable item inside fixed-pos element scrolled");
   // wait for it to layerize fully and then try again
   yield waitForAllPaints(function() {
     flushApzRepaints(testDriver);
   });
   scrollPos = fpos.scrollTop;
-  // The mouse is already at the right position. If we call scrollWheelOver it
+  // The mouse is already at the right position. If we call moveMouseAndScrollWheelOver it
   // hangs on windows waiting for the mouse-move, so instead we just synthesize
   // the wheel directly.
   yield synthesizeNativeWheelAndWaitForScrollEvent(fpos, 50, 150, 0, -10, testDriver);
   ok(fpos.scrollTop > scrollPos, "scrollable item inside fixed-pos element scrolled after layerization");
 
   // same, but using the top-level window's position:sticky element
   scrollPos = window.scrollY;
-  yield scrollWheelOver(document.body, 50, 150, testDriver);
+  yield moveMouseAndScrollWheelOver(document.body, 50, 150, testDriver);
   ok(window.scrollY > scrollPos, "top-level document scrolled after wheeling over the position:sticky element");
 
   // same, but using the top-level window's position:fixed element
   scrollPos = window.scrollY;
-  yield scrollWheelOver(document.body, 250, 150, testDriver);
+  yield moveMouseAndScrollWheelOver(document.body, 250, 150, testDriver);
   ok(window.scrollY > scrollPos, "top-level document scrolled after wheeling over the position:fixed element");
 }
 
 waitUntilApzStable()
 .then(runContinuation(test))
 .then(subtestDone);
 
   </script>