Bug 1323400 - Part 3-2: Add test; r=smaug
authorEdgar Chen <echen@mozilla.com>
Fri, 15 Feb 2019 21:53:44 +0000
changeset 459612 b49310f66efe744be9fbfeaaae0f2ea39cb7a6b7
parent 459611 8a29492017e3bea6a71c1ea2fd4c4c92150ec92a
child 459613 b29cead870d90f9c9333c6ef453a0e6c53d8a255
push id35563
push userccoroiu@mozilla.com
push dateSat, 16 Feb 2019 09:36:04 +0000
treeherdermozilla-central@1cfd69d05aa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1323400
milestone67.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 1323400 - Part 3-2: Add test; r=smaug Differential Revision: https://phabricator.services.mozilla.com/D19811
dom/events/test/pointerevents/test_multiple_touches.html
--- a/dom/events/test/pointerevents/test_multiple_touches.html
+++ b/dom/events/test/pointerevents/test_multiple_touches.html
@@ -72,16 +72,31 @@ function synthesizeTouchEnd(aTarget, aId
   touches.rys.splice(index, 1);
   touches.angles.splice(index, 1);
   touches.forces.splice(index, 1);
 
   synthesizeTouchEvent("touchend", [aId], [rect.left + aOffsetX], [rect.top + aOffsetY],
                        [1], [1], [0], [1]);
 }
 
+function synthesizeTouchMove(aTarget, aId, aOffsetX, aOffsetY) {
+  let index = touches.ids.indexOf(aId);
+  if (-1 === index) {
+    ok(false, `touch with id=${aTouch.id} isn't registered`);
+    return;
+  }
+
+  let rect = aTarget.getBoundingClientRect();
+  touches.lefts[index] = rect.left + aOffsetX;
+  touches.tops[index] = rect.top + aOffsetY;
+
+  synthesizeTouchEvent("touchmove", touches.ids, touches.lefts, touches.tops,
+                       touches.rxs, touches.rys, touches.angles, touches.forces);
+}
+
 var target0 = document.getElementById("target0");
 var target1 = document.getElementById("target1");
 
 function WaitExpectedEvents(aListenEvents, aExpectedEvents, aEventGenerator) {
   let promise = new Promise(function(aResolve) {
     let index = 0;
     let checkReceivedEvents = function(aEvent) {
       if (aExpectedEvents.length === 0) {
@@ -138,11 +153,38 @@ add_task(async function ShouldNotSendDup
       synthesizeTouchStart(target0, defaultId, 10, 10);
       synthesizeTouchStart(target1, defaultId + 1, 10, 10);
       synthesizeTouchEnd(target1, defaultId + 1, 10, 10);
       synthesizeTouchEnd(target0, defaultId, 10, 10);
     }
   );
 });
 
+// Test for bug 1323400
+add_task(async function ShouldNotSendDuplicatedPointerMove() {
+  return WaitExpectedEvents(
+    ["pointerup", "pointerdown","pointermove"],
+    [ // [event target, event type]
+      [target0, "pointerdown"],
+      [target1, "pointerdown"],
+      // The first pointermove should not be suppressed.
+      [target0, "pointermove"],
+      [target1, "pointermove"],
+      // Should receive only one pointer event for target 1.
+      [target1, "pointermove"],
+      [target1, "pointerup"],
+      [target0, "pointerup"],
+    ],
+    function() {
+      var defaultId = SpecialPowers.Ci.nsIDOMWindowUtils.DEFAULT_TOUCH_POINTER_ID;
+      synthesizeTouchStart(target0, defaultId, 10, 10);
+      synthesizeTouchStart(target1, defaultId + 1, 10, 10);
+      synthesizeTouchMove(target1, defaultId + 1, 11, 11);
+      synthesizeTouchMove(target1, defaultId + 1, 12, 12);
+      synthesizeTouchEnd(target1, defaultId + 1, 10, 10);
+      synthesizeTouchEnd(target0, defaultId, 10, 10);
+    }
+  );
+});
+
 </script>
 </body>
 </html>