Bug 1631923 [wpt PR 23151] - Migrate pointerevents/touch-pointercancel.html to wpt, a=testonly
authorNavid Zolghadr <nzolghadr@chromium.org>
Tue, 28 Apr 2020 11:37:27 +0000
changeset 527574 fb45c867b69d09c119cf38ccdcd0844066d4ebf8
parent 527573 ed97836553af5bc29989d8e941f331cf956394e7
child 527575 4cdada5d87dffd05db728efe8e1c5d43bc6cd7f8
push id37368
push userbtara@mozilla.com
push dateFri, 01 May 2020 21:45:51 +0000
treeherdermozilla-central@0f9c5a59e45d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1631923, 23151, 2159577, 761123
milestone77.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 1631923 [wpt PR 23151] - Migrate pointerevents/touch-pointercancel.html to wpt, a=testonly Automatic update from web-platform-tests Migrate pointerevents/touch-pointercancel.html to wpt pointerevents/touch-pointercancel.html test verifies the touch and pointer events interaction in single and multi touch point cases when scrolling happens or not. The single touch point portion is already tested as part of wpt/pointerevents/pointerevent_pointercancel_touch.html The two finger interaction is not very well specified and is tested as part of wpt/pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html and that only is missing the pointerid checks that this CL adds as well. Change-Id: I3ee27866dddc02cb87b1082b5a4fe2f9e8ba9220 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159577 Reviewed-by: Mustaq Ahmed <mustaq@chromium.org> Commit-Queue: Navid Zolghadr <nzolghadr@chromium.org> Cr-Commit-Position: refs/heads/master@{#761123} -- wpt-commits: eec9d65928b85f2ab8dc5252deb128d2246994af wpt-pr: 23151
testing/web-platform/tests/pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html
testing/web-platform/tests/pointerevents/pointerevent_support.js
--- a/testing/web-platform/tests/pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html
+++ b/testing/web-platform/tests/pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html
@@ -10,40 +10,24 @@
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/resources/testdriver.js"></script>
     <script src="/resources/testdriver-actions.js"></script>
     <script src="/resources/testdriver-vendor.js"></script>
     <script type="text/javascript" src="../pointerevent_support.js"></script>
     <script type="text/javascript">
       var event_log = [];
-      var active_pointers = 0;
       var actions_promise;
+      var down_ids = new Set();
+      var release_ids = new Set();
 
       function resetTestState() {
         event_log = [];
-        active_pointers = 0;
-      }
-
-      function twoFingerDrag(target) {
-        return new test_driver.Actions()
-                      .addPointer("touchPointer1", "touch")
-                      .addPointer("touchPointer2", "touch")
-                      .pointerMove(0, 0, {origin: target, sourceName: "touchPointer1"})
-                      .pointerMove(10, 0, {origin: target, sourceName: "touchPointer2"})
-                      .pointerDown({sourceName: "touchPointer1"})
-                      .pointerDown({sourceName: "touchPointer2"})
-                      .pointerMove(0, 10, {origin: target, sourceName: "touchPointer1"})
-                      .pointerMove(10, 10, {origin: target, sourceName: "touchPointer2"})
-                      .pointerMove(0, 20, {origin: target, sourceName: "touchPointer1"})
-                      .pointerMove(10, 20, {origin: target, sourceName: "touchPointer2"})
-                      .pause(100)
-                      .pointerUp({sourceName: "touchPointer1"})
-                      .pointerUp({sourceName: "touchPointer2"})
-                      .send();
+        down_ids = new Set();
+        release_ids = new Set();
       }
 
       function run() {
         var test_pointer_events = [
           setup_pointerevent_test("two-finger pan on 'touch-action: pan-x pan-y'", ["touch"]),
           setup_pointerevent_test("two-finger pan on 'touch-action: pinch-zoom'", ["touch"])
         ];
         var expected_events = [
@@ -52,20 +36,21 @@
         ];
         var current_test_index = 0;
         var black = document.getElementById("black");
         var grey = document.getElementById("grey");
         var done = document.getElementById("done");
 
         on_event(done, "click", function() {
           test_pointer_events[current_test_index].step(function () {
-            assert_equals(active_pointers, 0);
+            assert_equals(down_ids.size, 2);
+            assert_equals(release_ids.size, 2);
+            assert_true([...down_ids].every(value => release_ids.has(value)));
             assert_equals(event_log.join(", "), expected_events[current_test_index]);
           });
-          event_log = [];
 
           // Make sure the test finishes after all the input actions are completed.
           actions_promise.then( () => {
             test_pointer_events[current_test_index++].done();
             if (current_test_index < 2) {
               actions_promise = twoFingerDrag(grey).then(function() {
                 return clickInTarget("touch", done);
               });
@@ -76,19 +61,19 @@
         var targets = [black, grey];
 
         ["pointerdown", "pointerup", "pointercancel"].forEach(function(eventName) {
           targets.forEach(function(target){
             on_event(target, eventName, function (event) {
               event_log.push(event.type + "@" + event.target.id);
 
               if (event.type == "pointerdown") {
-                active_pointers++;
+                down_ids.add(event.pointerId);
               } else {
-                active_pointers--;
+                release_ids.add(event.pointerId);
               }
             });
           });
         });
 
         // Inject touch inputs.
         actions_promise = twoFingerDrag(black).then(function() {
           return clickInTarget("touch", done);
--- a/testing/web-platform/tests/pointerevents/pointerevent_support.js
+++ b/testing/web-platform/tests/pointerevents/pointerevent_support.js
@@ -291,16 +291,34 @@ function clickInTarget(pointerType, targ
     return new test_driver.Actions()
                    .addPointer(pointerId, pointerType)
                    .pointerMove(0, 0, {origin: target})
                    .pointerDown()
                    .pointerUp()
                    .send();
 }
 
+function twoFingerDrag(target) {
+  return new test_driver.Actions()
+      .addPointer("touchPointer1", "touch")
+      .addPointer("touchPointer2", "touch")
+      .pointerMove(0, 0, {origin: target, sourceName: "touchPointer1"})
+      .pointerMove(10, 0, {origin: target, sourceName: "touchPointer2"})
+      .pointerDown({sourceName: "touchPointer1"})
+      .pointerDown({sourceName: "touchPointer2"})
+      .pointerMove(0, 10, {origin: target, sourceName: "touchPointer1"})
+      .pointerMove(10, 10, {origin: target, sourceName: "touchPointer2"})
+      .pointerMove(0, 20, {origin: target, sourceName: "touchPointer1"})
+      .pointerMove(10, 20, {origin: target, sourceName: "touchPointer2"})
+      .pause(100)
+      .pointerUp({sourceName: "touchPointer1"})
+      .pointerUp({sourceName: "touchPointer2"})
+      .send();
+}
+
 function pointerDragInTarget(pointerType, target, direction) {
     var x_delta = 0;
     var y_delta = 0;
     if (direction == "down") {
         x_delta = 0;
         y_delta = 10;
     } else if (direction == "up") {
         x_delta = 0;