Bug 1712726 - Part 3: Add tests for coalescing mousewheel events. r=smaug
☠☠ backed out by 3e2960113395 ☠ ☠
authorBas Schouten <bschouten@mozilla.com>
Wed, 02 Jun 2021 23:42:31 +0000
changeset 654270 52dd9f9ddded7472fc023ad0fc466118a51611e9
parent 654269 98052e01cacdd7cb1b18a373d85ad16b7f96b62d
child 654271 a81b46bef82fcd2f0e63cae11464283abe9a2fce
push id2623
push userffxbld-merge
push dateMon, 02 Aug 2021 14:47:51 +0000
treeherdermozilla-release@8500ce65f7c6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1712726
milestone91.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 1712726 - Part 3: Add tests for coalescing mousewheel events. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D116431
dom/events/test/mochitest.ini
dom/events/test/test_coalesce_mousewheel.html
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -124,16 +124,17 @@ skip-if = toolkit == 'android' #CRASH_DU
 [test_bug684208.html]
 [test_bug689564.html]
 skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
 [test_bug698929.html]
 skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
 [test_bug704423.html]
 [test_bug741666.html]
 skip-if = toolkit == 'android' # fail
+[test_coalesce_mousewheel.html]
 [test_coalesce_touchmove.html]
 support-files = file_coalesce_touchmove.html
 skip-if = debug #In order to be able to test touchmoves, the test needs to synthesize touchstart in a way which asserts
 [test_deviceSensor.html]
 [test_bug812744.html]
 [test_bug822898.html]
 [test_bug855741.html]
 [test_bug864040.html]
new file mode 100644
--- /dev/null
+++ b/dom/events/test/test_coalesce_mousewheel.html
@@ -0,0 +1,116 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>mousewheel coalescing</title>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script src="/tests/SimpleTest/EventUtils.js"></script>
+  <script src="apz_test_utils.js"></script>
+  <script src="apz_test_native_event_utils.js"></script>
+  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
+  <script>
+  var mousewheelCount = 0;
+  function mousewheel() {
+    // Make mousewheel handling slow
+    var start = performance.now();
+    while (performance.now() < (start + 10));
+    ++mousewheelCount;
+  }
+
+  function resolveIfProcessed(resolve, minamount) {
+    if (mousewheelCount >= minamount) {
+      SimpleTest.requestFlakyTimeout("Make sure we got all events.");
+      setTimeout(function() { resolve(mousewheelCount); }, 20);
+    } else {
+      setTimeout(function() { resolveIfProcessed(resolve, minamount); });
+    }
+  }
+
+  async function fireOneSingleWheelEvent() {
+    var ret = new Promise(function(resolve) {
+      mousewheelCount = 0;
+      var element = document.getElementById("wheelEventReceiver");
+      element.addEventListener("wheel", mousewheel, true);
+
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+
+      setTimeout(function() { resolveIfProcessed(resolve, 1); });
+    });
+
+    return ret
+  }
+
+  async function fireTwoSingleWheelEvents() {
+    var ret = new Promise(function(resolve) {
+      mousewheelCount = 0;
+      var element = document.getElementById("wheelEventReceiver");
+      element.addEventListener("wheel", mousewheel, true);
+
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+
+      setTimeout(function() { resolveIfProcessed(resolve, 1); });
+    });
+
+    return ret
+  }
+  async function fireManySingleWheelEvents() {
+    var ret = new Promise(function(resolve) {
+      mousewheelCount = 0;
+      var element = document.getElementById("wheelEventReceiver");
+      element.addEventListener("wheel", mousewheel, true);
+
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+
+      setTimeout(function() { resolveIfProcessed(resolve, 1); });
+    });
+
+    return ret
+  }
+  async function fireMixedWheelEvents() {
+    var ret = new Promise(function(resolve) {
+      mousewheelCount = 0;
+      var element = document.getElementById("wheelEventReceiver");
+      element.addEventListener("wheel", mousewheel, true);
+
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_PAGE });
+      synthesizeWheel(element, 10, 10, { deltaY: 3.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
+
+      setTimeout(function() { resolveIfProcessed(resolve, 3); });
+    });
+
+    return ret
+  }
+
+  async function runTests() {
+    var enabled = SpecialPowers.getDOMWindowUtils(window).asyncPanZoomEnabled;
+
+    var oneMouseWheels = await fireOneSingleWheelEvent();
+    is(oneMouseWheels, 1,
+       "Should have gotten 1 wheel event");
+    var twoMouseWheelsWithCoalescing = await fireTwoSingleWheelEvents();
+    is(twoMouseWheelsWithCoalescing, 1,
+       "Should have gotten 1 wheel event");
+    var manyMouseWheelsWithCoalescing = await fireManySingleWheelEvents();
+    is(manyMouseWheelsWithCoalescing, 1,
+       "Should have gotten 1 wheel event");
+    var mixedMouseWheelsWithCoalescing = await fireMixedWheelEvents();
+    is(mixedMouseWheelsWithCoalescing, 3,
+       "Should have got 3 wheel event");
+
+    setTimeout("SimpleTest.finish()");
+    window.close();
+  }
+
+  </script>
+</head>
+<body onload="SimpleTest.waitForFocus(runTests);">
+  <div id="wheelEventReceiver" style="width:100px;height:100px;"></div>
+</body>
+</html>