Bug 1175585 - Generalize scrollWheelOver() so it's usable by other APZ tests. r=kats
☠☠ backed out by 2f952a21d83c ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Wed, 17 Jun 2015 19:11:25 -0400
changeset 267948 89b4c0b06ff3839c2e263bf5c2cac68adb1a07bd
parent 267947 69a9775dc5c921d180a4fef1d2e7812610e70d56
child 267949 5b56c3d0e3796fcd86cb1fd48d95208abba93353
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1175585
milestone41.0a1
Bug 1175585 - Generalize scrollWheelOver() so it's usable by other APZ tests. r=kats
gfx/layers/apz/test/apz_test_native_event_utils.js
gfx/layers/apz/test/test_layerization.html
--- a/gfx/layers/apz/test/apz_test_native_event_utils.js
+++ b/gfx/layers/apz/test/apz_test_native_event_utils.js
@@ -119,8 +119,28 @@ function synthesizeNativeMouseMove(aElem
 function synthesizeNativeMouseMoveAndWaitForMoveEvent(aElement, aX, aY, aCallback) {
   var targetWindow = aElement.ownerDocument.defaultView;
   targetWindow.addEventListener("mousemove", function mousemoveWaiter(e) {
     targetWindow.removeEventListener("mousemove", mousemoveWaiter);
     setTimeout(aCallback, 0);
   });
   return synthesizeNativeMouseMove(aElement, aX, aY);
 }
+
+// Scroll the mouse wheel (in the vertical direction) by |aWheelDelta| over |aElement|,
+// calling |aCallback| when the first resulting scroll event is received.
+function scrollWheelOver(aElement, aWheelDelta, aCallback) {
+  var scale = window.devicePixelRatio;
+  var rect = aElement.getBoundingClientRect();
+  var x = (rect.left + 10) * scale;
+  var y = (rect.top + 10) * scale;
+  // 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.
+  synthesizeNativeMouseMoveAndWaitForMoveEvent(aElement, x, y, function() {
+    synthesizeNativeWheelAndWaitForScrollEvent(aElement, x, y, 0, aWheelDelta, aCallback);
+  });
+}
+
--- a/gfx/layers/apz/test/test_layerization.html
+++ b/gfx/layers/apz/test/test_layerization.html
@@ -45,32 +45,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <!-- The page-content div ensures the page is scrollable, so none of the
      subframes are layerized by the optimization that layerizes the
      primary async-scrollable frame on page load. -->
 <div id="page-content"></div>
 <pre id="test">
 <script type="application/javascript;version=1.7">
 
-// Scroll the mouse wheel over |element|.
-function scrollWheelOver(element) {
-  var scale = window.devicePixelRatio;
-  var rect = element.getBoundingClientRect();
-  var x = (rect.left + 10) * scale;
-  var y = (rect.top + 10) * scale;
-  // 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.
-  synthesizeNativeMouseMoveAndWaitForMoveEvent(element, x, y, function() {
-    synthesizeNativeWheelAndWaitForScrollEvent(element, x, y, 0, -10, driveTest);
-  });
+function scrollWheel(element) {
+    scrollWheelOver(element, -10, driveTest);
 }
 
 var gTestContinuation = null;
 var utils;
 
 // Return whether the element with id |elementId| has been layerized.
 // Assumes |elementId| will be present in the content description for the
 // element, and not in the content descriptions of other elements.
@@ -99,35 +85,35 @@ function* runTest() {
   ok(!isLayerized('outer2'), "initially 'outer2' should not be layerized");
   ok(!isLayerized('inner2'), "initially 'inner2' should not be layerized");
   ok(!isLayerized('outer3'), "initially 'outer3' should not be layerized");
   ok(!isLayerized('inner3'), "initially 'inner3' should not be layerized");
   ok(!isLayerized('outer4'), "initially 'outer4' should not be layerized");
   ok(!isLayerized('inner4'), "initially 'inner4' should not be layerized");
 
   // Scrolling over outer1 should layerize outer1, but not inner1.
-  yield scrollWheelOver(document.getElementById('outer1'));
+  yield scrollWheel(document.getElementById('outer1'));
   ok(isLayerized('outer1'), "scrolling 'outer1' should cause it to be layerized");
   ok(!isLayerized('inner1'), "scrolling 'outer1' should not cause 'inner1' to be layerized");
 
   // Scrolling over inner2 should layerize both outer2 and inner2.
-  yield scrollWheelOver(document.getElementById('inner2'));
+  yield scrollWheel(document.getElementById('inner2'));
   ok(isLayerized('inner2'), "scrolling 'inner2' should cause it to be layerized");
   ok(isLayerized('outer2'), "scrolling 'inner2' should also cause 'outer2' to be layerized");
 
   // The second half of the test repeats the same checks as the first half,
   // but with an iframe as the outer scrollable frame.
 
   // Scrolling over outer3 should layerize outer3, but not inner3.
-  yield scrollWheelOver(document.getElementById('outer3').contentDocument.documentElement);
+  yield scrollWheel(document.getElementById('outer3').contentDocument.documentElement);
   ok(isLayerized('outer3'), "scrolling 'outer3' should cause it to be layerized");
   ok(!isLayerized('inner3'), "scrolling 'outer3' should not cause 'inner3' to be layerized");
 
   // Scrolling over outer4 should layerize both outer4 and inner4.
-  yield scrollWheelOver(document.getElementById('outer4').contentDocument.getElementById('inner4'));
+  yield scrollWheel(document.getElementById('outer4').contentDocument.getElementById('inner4'));
   ok(isLayerized('inner4'), "scrolling 'inner4' should cause it to be layerized");
   ok(isLayerized('outer4'), "scrolling 'inner4' should also cause 'outer4' to be layerized");
 }
 
 function driveTest() {
   if (!gTestContinuation) {
     gTestContinuation = runTest();
   }