Bug 1351148 Part7: Revise window_wheel_default_action.html to wait event 'FullZoomChange' and then check the result. r=smaug.
authorStone Shih <sshih@mozilla.com>
Fri, 07 Jul 2017 11:48:42 +0800
changeset 418896 fcdaffc1de9fcc71d37c60f807be7d2885bb6fc6
parent 418895 7adefc652d954eaa83cb4e2a871cf2a153f3f9ea
child 418897 0ee0458b1452f8be4502807ff78109ae4b0fa821
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1351148
milestone56.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 1351148 Part7: Revise window_wheel_default_action.html to wait event 'FullZoomChange' and then check the result. r=smaug. MozReview-Commit-ID: E56dfMIxtSl
dom/events/test/window_wheel_default_action.html
--- a/dom/events/test/window_wheel_default_action.html
+++ b/dom/events/test/window_wheel_default_action.html
@@ -1136,37 +1136,61 @@ function doTestZoom(aSettings, aCallback
     event.ctrlKey  = true;
 
     // NOTE: Zooming might change scrollTop and scrollLeft by rounding fraction.
     //       This test assume that zoom happens synchronously and scrolling
     //       happens asynchronously.
     var scrollTop = gScrollableElement.scrollTop;
     var scrollLeft = gScrollableElement.scrollLeft;
 
+    fullZoomChangePromise = new Promise(resolve => {
+      if (currentTest.expected & (kNegative | kPositive)) {
+        SpecialPowers.addChromeEventListener("FullZoomChange", function onFullZoomChange() {
+          if (SpecialPowers.getFullZoom(window) != 1) {
+            SpecialPowers.removeChromeEventListener("FullZoomChange", onFullZoomChange)
+            setTimeout(() => resolve(), 0);
+          }
+        });
+      } else {
+        resolve();
+      }
+    });
+
     sendWheelAndWait(10, 10, event, function () {
       is(gScrollableElement.scrollTop, scrollTop, description + "scrolled vertical");
       is(gScrollableElement.scrollLeft, scrollLeft, description + "scrolled horizontal");
-      if (!(currentTest.expected & (kNegative | kPositive))) {
-        is(SpecialPowers.getFullZoom(window), 1.0, description + "zoomed");
-      } else {
-        var isReverted = (currentTest.expected & kUseX) ? isXReverted :
-                         (currentTest.expected & kUseY) ? isYReverted : false;
-        if ((!isReverted && (currentTest.expected & kNegative)) ||
-            (isReverted && (currentTest.expected & kPositive))) {
-          ok(SpecialPowers.getFullZoom(window) > 1.0,
-             description + "not zoomed in, got " + SpecialPowers.getFullZoom(window));
+
+      fullZoomChangePromise.then(() => {
+        // When input event prioritization is enabled, the wheel event may be
+        // dispatched to the content process before the message 'FullZoom' to
+        // zoom in/out. Waiting for the event 'FullZoomChange' and then check
+        // the result.
+        if (!(currentTest.expected & (kNegative | kPositive))) {
+          is(SpecialPowers.getFullZoom(window), 1.0, description + "zoomed");
         } else {
-          ok(SpecialPowers.getFullZoom(window) < 1.0,
-             description + "not zoomed out, got " + SpecialPowers.getFullZoom(window));
+          var isReverted = (currentTest.expected & kUseX) ? isXReverted :
+                           (currentTest.expected & kUseY) ? isYReverted : false;
+          if ((!isReverted && (currentTest.expected & kNegative)) ||
+              (isReverted && (currentTest.expected & kPositive))) {
+            ok(SpecialPowers.getFullZoom(window) > 1.0,
+               description + "not zoomed in, got " + SpecialPowers.getFullZoom(window));
+          } else {
+            ok(SpecialPowers.getFullZoom(window) < 1.0,
+               description + "not zoomed out, got " + SpecialPowers.getFullZoom(window));
+          }
         }
-      }
-
-      synthesizeKey("0", { accelKey: true });
-      onZoomReset(function () {
-        hitEventLoop(doNextTest, 20);
+        if (SpecialPowers.getFullZoom(window) != 1) {
+          // Only synthesizes key event to reset zoom when necessary to avoid
+          // triggering the next test before the key event is handled. In that
+          // case, the key event may break the next test.
+          synthesizeKey("0", { accelKey: true });
+        }
+        onZoomReset(function () {
+          hitEventLoop(doNextTest, 20);
+        });
       });
     });
   }
   doNextTest();
 }
 
 function doTestZoomedScroll(aCallback)
 {