Bug 1251905, part 4 - Use pushPrefEnv in testContinuousTrustedEvents(). r=masayuki
authorAndrew McCreight <continuation@gmail.com>
Sat, 02 Apr 2016 10:30:31 -0700
changeset 291483 7c052af6963b9a0bb2f83aaab90cddbd5732b0bd
parent 291482 94d3753f21e27a8579c691cf77ae76da6c625c70
child 291484 9ac7cea0096fb106beae78396dfb645fe8eb4cb5
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
bugs1251905
milestone48.0a1
Bug 1251905, part 4 - Use pushPrefEnv in testContinuousTrustedEvents(). r=masayuki
dom/events/test/test_continuous_wheel_events.html
--- a/dom/events/test/test_continuous_wheel_events.html
+++ b/dom/events/test/test_continuous_wheel_events.html
@@ -103,17 +103,17 @@ function* prepareScrollUnits()
 
   window.removeEventListener("MozMousePixelScroll", handler, true);
 }
 
 // Tests continuous trusted wheel events. Trusted wheel events should cause
 // legacy mouse scroll events when its lineOrPageDelta value is not zero or
 // accumulated delta values of pixel scroll events of pixel only device
 // become over the line height.
-function testContinuousTrustedEvents()
+function* testContinuousTrustedEvents()
 {
   const kSynthesizedWheelEventTests = [
     { description: "Simple horizontal wheel event by pixels (16.0 - 1) #1",
       event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
                deltaX: 16.0, deltaY: 0.0, deltaZ: 0.0, isMomentum: false,
                lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isNoLineOrPageDelta: false,
                isCustomizedByPrefs: false,
                shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
@@ -2662,18 +2662,19 @@ function testContinuousTrustedEvents()
       MozMousePixelScroll: {
         horizontal: { expected: true,  preventDefault: false, detail: gPageWidth },
         vertical:   { expected: true,  preventDefault: false, detail: gPageHeight } },
     },
 
     // Tests for accumulation delta when delta_multiplier_is customized.
     { description: "lineOrPageDelta should be recomputed by ESM (pixel) #1",
       prepare: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 200);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 300);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 200],
+                                           ["mousewheel.default.delta_multiplier_y", 300]]},
+                                  continueTest);
       },
       event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
                deltaX: gHorizontalLine / 4, deltaY: gLineHeight / 8, deltaZ: 0,
                lineOrPageDeltaX: 3, lineOrPageDeltaY: 5, isNoLineOrPageDelta: false,
                isCustomizedByPrefs: false,
                shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
       wheel: {
         expected: true, preventDefault: false,
@@ -2715,25 +2716,27 @@ function testContinuousTrustedEvents()
       },
       DOMMouseScroll: {
         horizontal: { expected: false,  preventDefault: false, detail: 0 },
         vertical:   { expected: true,   preventDefault: false, detail: 1 } },
       MozMousePixelScroll: {
         horizontal: { expected: true,   preventDefault: false, detail: Math.floor((gHorizontalLine / 4 + 1) * 2) },
         vertical:   { expected: true,   preventDefault: false, detail: Math.floor((gLineHeight / 8 + 1) * 3) } },
       finished: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 100);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 100],
+                                           ["mousewheel.default.delta_multiplier_y", 100]]},
+                                  continueTest);
       },
     },
 
     { description: "lineOrPageDelta should be recomputed by ESM (pixel, negative, shift) #1",
       prepare: function () {
-        SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_x", 200);
-        SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_y", 300);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.with_shift.delta_multiplier_x", 200],
+                                           ["mousewheel.with_shift.delta_multiplier_y", 300]]},
+                                  continueTest);
       },
       event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
                deltaX: -gHorizontalLine / 4, deltaY: -gLineHeight / 8, deltaZ: 0,
                lineOrPageDeltaX: -3, lineOrPageDeltaY: -5, isNoLineOrPageDelta: false,
                isCustomizedByPrefs: false,
                shiftKey: true, ctrlKey: false, altKey: false, metaKey: false },
       wheel: {
         expected: true, preventDefault: false,
@@ -2775,25 +2778,27 @@ function testContinuousTrustedEvents()
       },
       DOMMouseScroll: {
         horizontal: { expected: false,  preventDefault: false, detail: 0 },
         vertical:   { expected: true,   preventDefault: false, detail: -1 } },
       MozMousePixelScroll: {
         horizontal: { expected: true,   preventDefault: false, detail: Math.ceil(-(gHorizontalLine / 4 + 1) * 2) },
         vertical:   { expected: true,   preventDefault: false, detail: Math.ceil(-(gLineHeight / 8 + 1) * 3) } },
       finished: function () {
-        SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_x", 100);
-        SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_y", 100);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.with_shift.delta_multiplier_x", 100],
+                                           ["mousewheel.with_shift.delta_multiplier_y", 100]]},
+                                  continueTest);
       },
     },
 
     { description: "lineOrPageDelta should be recomputed by ESM (line) #1",
       prepare: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 200);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 100);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 200],
+                                           ["mousewheel.default.delta_multiplier_y", 100]]},
+                                  continueTest);
       },
       event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
                deltaX: 0.3, deltaY: 0.4, deltaZ: 0,
                lineOrPageDeltaX: 3, lineOrPageDeltaY: 5, isNoLineOrPageDelta: false,
                isCustomizedByPrefs: false,
                shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
       wheel: {
         expected: true, preventDefault: false,
@@ -2835,25 +2840,27 @@ function testContinuousTrustedEvents()
       },
       DOMMouseScroll: {
         horizontal: { expected: false, preventDefault: false, detail: 0 },
         vertical:   { expected: true,  preventDefault: false, detail: 1 } },
       MozMousePixelScroll: {
         horizontal: { expected: true,  preventDefault: false, detail: Math.floor(gHorizontalLine * 0.6) },
         vertical:   { expected: true,  preventDefault: false, detail: Math.floor(gLineHeight * 0.4) } },
       finished: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 100);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 100],
+                                           ["mousewheel.default.delta_multiplier_y", 100]]},
+                                  continueTest);
       },
     },
 
     { description: "lineOrPageDelta should be recomputed by ESM (line, negative) #1",
       prepare: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 200);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", -100);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 200],
+                                           ["mousewheel.default.delta_multiplier_y", -100]]},
+                                  continueTest);
       },
       event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
                deltaX: -0.3, deltaY: -0.4, deltaZ: 0,
                lineOrPageDeltaX: -3, lineOrPageDeltaY: -5, isNoLineOrPageDelta: false,
                isCustomizedByPrefs: false,
                shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
       wheel: {
         expected: true, preventDefault: false,
@@ -2895,25 +2902,27 @@ function testContinuousTrustedEvents()
       },
       DOMMouseScroll: {
         horizontal: { expected: false, preventDefault: false, detail: 0 },
         vertical:   { expected: true,  preventDefault: false, detail: 1 } },
       MozMousePixelScroll: {
         horizontal: { expected: true,  preventDefault: false, detail: Math.ceil(gHorizontalLine * -0.6) },
         vertical:   { expected: true,  preventDefault: false, detail: Math.floor(gLineHeight * 0.4) } },
       finished: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 100);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 100],
+                                           ["mousewheel.default.delta_multiplier_y", 100]]},
+                                  continueTest);
       },
     },
 
     { description: "lineOrPageDelta should be recomputed by ESM (page) #1",
       prepare: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 200);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 100],
+                                           ["mousewheel.default.delta_multiplier_y", 200]]},
+                                  continueTest);
       },
       event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
                deltaX: 0.3, deltaY: 0.4, deltaZ: 0,
                lineOrPageDeltaX: 3, lineOrPageDeltaY: 5, isNoLineOrPageDelta: false,
                isCustomizedByPrefs: false,
                shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
       wheel: {
         expected: true, preventDefault: false,
@@ -2955,25 +2964,27 @@ function testContinuousTrustedEvents()
       },
       DOMMouseScroll: {
         horizontal: { expected: true,  preventDefault: false, detail: UIEvent.SCROLL_PAGE_DOWN },
         vertical:   { expected: true,  preventDefault: false, detail: UIEvent.SCROLL_PAGE_DOWN } },
       MozMousePixelScroll: {
         horizontal: { expected: true,  preventDefault: false, detail: Math.floor(gPageWidth * 0.4) },
         vertical:   { expected: true,  preventDefault: false, detail: Math.floor(gPageHeight * 0.8) } },
       finished: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 100);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 100],
+                                           ["mousewheel.default.delta_multiplier_y", 100]]},
+                                  continueTest);
       },
     },
 
     { description: "lineOrPageDelta should be recomputed by ESM (page, negative) #1",
       prepare: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 200);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 100],
+                                           ["mousewheel.default.delta_multiplier_y", 200]]},
+                                  continueTest);
       },
       event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
                deltaX: -0.3, deltaY: -0.4, deltaZ: 0,
                lineOrPageDeltaX: -3, lineOrPageDeltaY: -5, isNoLineOrPageDelta: false,
                isCustomizedByPrefs: false,
                shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
       wheel: {
         expected: true, preventDefault: false,
@@ -3015,18 +3026,19 @@ function testContinuousTrustedEvents()
       },
       DOMMouseScroll: {
         horizontal: { expected: true,  preventDefault: false, detail: UIEvent.SCROLL_PAGE_UP },
         vertical:   { expected: true,  preventDefault: false, detail: UIEvent.SCROLL_PAGE_UP } },
       MozMousePixelScroll: {
         horizontal: { expected: true,  preventDefault: false, detail: Math.ceil(gPageWidth * -0.4) },
         vertical:   { expected: true,  preventDefault: false, detail: Math.ceil(gPageHeight * -0.8) } },
       finished: function () {
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
-        SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 100);
+        SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.delta_multiplier_x", 100],
+                                           ["mousewheel.default.delta_multiplier_y", 100]]},
+                                  continueTest);
       },
     },
   ];
 
   var currentWheelEventTest;
   var calledHandlers = { wheel: false,
                          DOMMouseScroll: { horizontal: false, vertical: false },
                          MozMousePixelScroll: { horizontal: false, vertical: false } };
@@ -3146,23 +3158,23 @@ function testContinuousTrustedEvents()
   window.addEventListener("MozMousePixelScroll", legacyEventHandler, true);
 
   for (var i = 0; i < kSynthesizedWheelEventTests.length; i++) {
     gScrollableElement.scrollTop = gScrollableElement.scrollBottom = 1000;
 
     currentWheelEventTest = kSynthesizedWheelEventTests[i];
 
     if (currentWheelEventTest.prepare) {
-      currentWheelEventTest.prepare();
+      yield currentWheelEventTest.prepare();
     }
 
     synthesizeWheel(gScrollableElement, 10, 10, currentWheelEventTest.event);
 
     if (currentWheelEventTest.finished) {
-      currentWheelEventTest.finished();
+      yield currentWheelEventTest.finished();
     }
 
     var description = "testContinuousTrustedEvents, " +
       currentWheelEventTest.description + ": ";
     is(calledHandlers.wheel, currentWheelEventTest.wheel.expected,
        description + "wheel event was fired or not fired");
     is(calledHandlers.DOMMouseScroll.horizontal,
        currentWheelEventTest.DOMMouseScroll.horizontal.expected,
@@ -3198,17 +3210,17 @@ function continueTest()
   if (ret.done) {
     SimpleTest.finish();
   }
 }
 
 function* testBody()
 {
   yield* prepareScrollUnits();
-  testContinuousTrustedEvents();
+  yield* testContinuousTrustedEvents();
 }
 
 function runTests()
 {
   SpecialPowers.pushPrefEnv({"set": [
     ["mousewheel.transaction.timeout", 100000],
     ["mousewheel.default.delta_multiplier_x", 100],
     ["mousewheel.default.delta_multiplier_y", 100],