Refactor test_bug422132. (bug 1149128, r=kats)
authorDavid Anderson <danderson@mozilla.com>
Wed, 15 Apr 2015 16:37:04 -0400
changeset 257506 8732f95f12f0ae501e7826d16da39a329c1e14d9
parent 257505 7654cc4ef41f6dba53d03d4df73e3683d425c6d5
child 257507 e4d3753af8a2a3ae8d28469e4e191c27cf499343
push id1545
push usermartin.thomson@gmail.com
push dateWed, 15 Apr 2015 21:23:43 +0000
reviewerskats
bugs422132, 1149128
milestone40.0a1
Refactor test_bug422132. (bug 1149128, r=kats)
dom/events/test/test_bug422132.html
--- a/dom/events/test/test_bug422132.html
+++ b/dom/events/test/test_bug422132.html
@@ -42,53 +42,89 @@ function hitEventLoop(aFunc, aTimes)
 }
 
 function runTests()
 {
   var target = document.getElementById("target");
 
   var scrollLeft = target.scrollLeft;
   var scrollTop = target.scrollTop;
-  synthesizeWheel(target, 10, 10,
-    { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
-      deltaX: 0.5, deltaY: 0.5, lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 });
-  hitEventLoop(function () {
-    is(target.scrollLeft, scrollLeft, "scrolled to right by 0.5px delta value");
-    is(target.scrollTop, scrollTop, "scrolled to bottom by 0.5px delta value");
-    scrollLeft = target.scrollLeft;
-    scrollTop = target.scrollTop;
-    synthesizeWheel(target, 10, 10,
-      { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
-        deltaX: 0.5, deltaY: 0.5, lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 });
-    hitEventLoop(function () {
-      ok(target.scrollLeft > scrollLeft,
-         "not scrolled to right by 0.5px delta value with pending 0.5px delta");
-      ok(target.scrollTop > scrollTop,
-         "not scrolled to bottom by 0.5px delta value with pending 0.5px delta");
+
+  var tests = [
+    {
+      event: {
+        deltaMode: WheelEvent.DOM_DELTA_PIXEL,
+        deltaX: 0.5,
+        deltaY: 0.5,
+        lineOrPageDeltaX: 0,
+        lineOrPageDeltaY: 0
+      },
+      check: function() {
+        is(target.scrollLeft, scrollLeft, "scrolled to right by 0.5px delta value");
+        is(target.scrollTop, scrollTop, "scrolled to bottom by 0.5px delta value");
+      }
+    }, {
+      event: {
+        deltaMode: WheelEvent.DOM_DELTA_PIXEL,
+        deltaX: 0.5,
+        deltaY: 0.5,
+        lineOrPageDeltaX: 0,
+        lineOrPageDeltaY: 0
+      },
+      check: function() {
+        ok(target.scrollLeft > scrollLeft,
+           "not scrolled to right by 0.5px delta value with pending 0.5px delta");
+        ok(target.scrollTop > scrollTop,
+           "not scrolled to bottom by 0.5px delta value with pending 0.5px delta");
+      },
+    }, {
+      event: {
+        deltaMode: WheelEvent.DOM_DELTA_LINE,
+        deltaX: 0.5,
+        deltaY: 0.5,
+        lineOrPageDeltaX: 0,
+        lineOrPageDeltaY: 0
+      },
+      check: function() {
+        is(target.scrollLeft, scrollLeft, "scrolled to right by 0.5 line delta value");
+        is(target.scrollTop, scrollTop, "scrolled to bottom by 0.5 line delta value");
+      }
+    }, {
+      event: {
+        deltaMode: WheelEvent.DOM_DELTA_LINE,
+        deltaX: 0.5,
+        deltaY: 0.5,
+        lineOrPageDeltaX: 1,
+        lineOrPageDeltaY: 1
+      },
+      check: function() {
+        ok(target.scrollLeft > scrollLeft,
+           "not scrolled to right by 0.5 line delta value with pending 0.5 line delta");
+        ok(target.scrollTop > scrollTop,
+           "not scrolled to bottom by 0.5 line delta value with pending 0.5 line delta");
+      }
+    }
+  ];
+
+  var nextTest = function() {
+    var test = tests.shift();
+    synthesizeWheel(target, 10, 10, test.event);
+    hitEventLoop(function() {
+      test.check();
+      if (tests.length == 0) {
+        SimpleTest.finish();
+        return;
+      }
+
       scrollLeft = target.scrollLeft;
       scrollTop = target.scrollTop;
-      synthesizeWheel(target, 10, 10,
-        { deltaMode: WheelEvent.DOM_DELTA_LINE,
-          deltaX: 0.5, deltaY: 0.5, lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 });
-      hitEventLoop(function () {
-        is(target.scrollLeft, scrollLeft, "scrolled to right by 0.5 line delta value");
-        is(target.scrollTop, scrollTop, "scrolled to bottom by 0.5 line delta value");
-        scrollLeft = target.scrollLeft;
-        scrollTop = target.scrollTop;
-        synthesizeWheel(target, 10, 10,
-          { deltaMode: WheelEvent.DOM_DELTA_LINE,
-            deltaX: 0.5, deltaY: 0.5, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 });
-        hitEventLoop(function () {
-          ok(target.scrollLeft > scrollLeft,
-             "not scrolled to right by 0.5 line delta value with pending 0.5 line delta");
-          ok(target.scrollTop > scrollTop,
-             "not scrolled to bottom by 0.5 line delta value with pending 0.5 line delta");
-          SimpleTest.finish();
-        }, 20);
-      }, 20);
+
+      setTimeout(nextTest, 0);
     }, 20);
-  }, 20);
+  }
+
+  nextTest();
 }
 
 </script>
 </pre>
 </body>
 </html>