Bug 1260148 - Make sendWheelAndPaint wait for the system wheel event. r=masayuki
authorAndrew McCreight <continuation@gmail.com>
Sat, 02 Apr 2016 10:30:30 -0700
changeset 291479 61676174a225c0a5b5dd23a71919f4cff84f7f56
parent 291478 8038df809897f0780cc4d585241fbef79d555b5f
child 291480 2c53434f2bec6eacc91c67a59ae9782396e17787
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1260148
milestone48.0a1
Bug 1260148 - Make sendWheelAndPaint wait for the system wheel event. r=masayuki This ensures that all of the legacy events have been fired.
testing/mochitest/tests/SimpleTest/EventUtils.js
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -572,17 +572,17 @@ function sendWheelAndPaint(aTarget, aOff
     // just wait for the paint to complete.
     aWindow.waitForAllPaintsFlushed(function() {
       sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, aEvent, aCallback, aWindow);
     });
     return;
   }
 
   var onwheel = function() {
-    window.removeEventListener("wheel", onwheel);
+    SpecialPowers.removeSystemEventListener(window, "wheel", onwheel);
 
     // Wait one frame since the wheel event has not caused a refresh observer
     // to be added yet.
     setTimeout(function() {
       utils.advanceTimeAndRefresh(1000);
 
       if (!aCallback) {
         utils.advanceTimeAndRefresh(0);
@@ -599,17 +599,19 @@ function sendWheelAndPaint(aTarget, aOff
 
       SpecialPowers.Services.obs.addObserver(waitForPaints, "apz-repaints-flushed", false);
       if (!utils.flushApzRepaints(aWindow)) {
         waitForPaints();
       }
     }, 0);
   };
 
-  aWindow.addEventListener("wheel", onwheel);
+  // Listen for the system wheel event, because it happens after all of
+  // the other wheel events, including legacy events.
+  SpecialPowers.addSystemEventListener(aWindow, "wheel", onwheel);
   synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow);
 }
 
 function synthesizeNativeMouseMove(aTarget, aOffsetX, aOffsetY, aCallback, aWindow = window) {
   var utils = _getDOMWindowUtils(aWindow);
   if (!utils)
     return;