Bug 1509959 - Add a mochitest to verify unconsumed panning events don't trigger a pointercancel. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 28 Nov 2018 19:01:47 +0000
changeset 504998 abbe480903f5043b3507208798ee7c84fcc0f03c
parent 504997 4e1a901cc0a5b0ca50f00cc929a967e0e6c0063e
child 504999 1bbf691c2a7ef844d76d45ff5a3ecb50ab91d415
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1509959
milestone65.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 1509959 - Add a mochitest to verify unconsumed panning events don't trigger a pointercancel. r=botond Differential Revision: https://phabricator.services.mozilla.com/D13148
gfx/layers/apz/test/mochitest/helper_bug1502010_unconsumed_pan.html
gfx/layers/apz/test/mochitest/test_group_pointerevents.html
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_bug1502010_unconsumed_pan.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width; initial-scale=1.0">
+  <title>Test pointercancel doesn't get sent for horizontal panning on a pan-y element</title>
+  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+  <script type="application/javascript" src="apz_test_utils.js"></script>
+  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
+  <script type="application/javascript">
+    var pointerMoveCount = 0;
+    var lastPointerCoord = -1;
+    var apzFlushed = false;
+    var endEventReceived = false;
+
+    function checkForTestEnd() {
+        if (apzFlushed && endEventReceived) {
+            var target = document.getElementById('carousel');
+            target.removeEventListener('pointermove', moveListener);
+
+            ok(pointerMoveCount > 0, "Got " + pointerMoveCount + " pointermove events");
+            is(document.scrollingElement.scrollTop, 0, "Document didn't y-scroll");
+            is(document.scrollingElement.scrollLeft, 0, "Document didn't x-scroll");
+
+            subtestDone();
+        }
+    }
+
+    function moveListener(event) {
+        ok(event.clientX >= lastPointerCoord, "Got nondecreasing pointermove to " + event.clientX + "," + event.clientY);
+        lastPointerCoord = event.clientX;
+        pointerMoveCount++;
+    }
+
+    function* test(testDriver) {
+        var target = document.getElementById('carousel');
+        target.addEventListener('pointercancel', (event) => {
+            ok(false, "Received pointercancel, uh-oh!");
+            endEventReceived = true;
+            setTimeout(checkForTestEnd, 0);
+        }, {once: true});
+        target.addEventListener('pointerup', () => {
+            ok(true, "Received pointerup");
+            endEventReceived = true;
+            setTimeout(checkForTestEnd, 0);
+        }, {once: true});
+
+        target.addEventListener('pointermove', moveListener);
+
+        // Drag mostly horizontally but also slightly vertically. If the
+        // touch-action were not respected due to a bug this might result
+        // in vertical scrolling instead of pointermove events.
+        yield synthesizeNativeTouchDrag(target, 10, 10, 200, -10, testDriver);
+        yield flushApzRepaints(testDriver);
+        apzFlushed = true;
+
+        setTimeout(checkForTestEnd, 0);
+    }
+
+    waitUntilApzStable().then(runContinuation(test));
+
+  </script>
+</head>
+<body>
+  <div id="carousel" style="height: 50px; touch-action: pan-y; background-color: blue"></div>
+  <div id="spacer" style="height: 2000px"></div>
+</body>
+</html>
--- a/gfx/layers/apz/test/mochitest/test_group_pointerevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_pointerevents.html
@@ -7,23 +7,24 @@ https://bugzilla.mozilla.org/show_bug.cg
   <meta charset="utf-8">
   <title>Test for Bug 1285070</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="apz_test_utils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   let isWindows = navigator.platform.indexOf("Win") == 0;
+  let enablePE = ["dom.w3c_pointer_events.enabled", true];
   var subtests = [
-    {'file': 'helper_bug1285070.html', 'prefs': [["dom.w3c_pointer_events.enabled", true]]},
-    {'file': 'helper_bug1299195.html', 'prefs': [["dom.w3c_pointer_events.enabled", true]]},
-    {'file': 'helper_bug1414336.html', 'prefs': [
-      ["dom.w3c_pointer_events.enabled", true],
+    {'file': 'helper_bug1285070.html', 'prefs': [enablePE]},
+    {'file': 'helper_bug1299195.html', 'prefs': [enablePE]},
+    {'file': 'helper_bug1414336.html', 'prefs': [enablePE,
       ["apz.test.fails_with_native_injection", isWindows]
-    ]}
+    ]},
+    {'file': 'helper_bug1502010_unconsumed_pan.html', 'prefs': [enablePE]}
   ];
 
   if (isApzEnabled()) {
     SimpleTest.waitForExplicitFinish();
     window.onload = function() {
       runSubtestsSeriallyInFreshWindows(subtests)
       .then(SimpleTest.finish, SimpleTest.finish);
     };