Skip to content

Commit 1d99362

Browse files
Olli Pettaymoz-wptsync-bot
authored andcommitted
[Pointer Event] pointermove will only be detected for one finger with multiple touches when preventDefault is used
Differential Revision: https://phabricator.services.mozilla.com/D330349 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1524251 gecko-commit: 35e398abc7e36a0d42947ef48cf53d667843211b gecko-commit-git: fa1277c79cf842c5e9bcfed0d5f0dc1eb1c3e801 gecko-reviewers: edgar
1 parent 172557b commit 1d99362

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width">
4+
<title>Pointer events of all touches after preventDefault() on pointerdown</title>
5+
<link rel="help" href="https://w3c.github.io/pointerevents/#the-pointerdown-event">
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
<script src="/resources/testdriver.js"></script>
9+
<script src="/resources/testdriver-actions.js"></script>
10+
<script src="/resources/testdriver-vendor.js"></script>
11+
<style>
12+
#target {
13+
width: 300px;
14+
height: 300px;
15+
touch-action: none;
16+
}
17+
</style>
18+
<div id="target"></div>
19+
<script>
20+
"use strict";
21+
22+
const target = document.getElementById("target");
23+
24+
function recordPointerEvents(t) {
25+
const events = new Map();
26+
const listener = e => {
27+
if (e.pointerType != "touch") {
28+
return;
29+
}
30+
if (!events.has(e.pointerId)) {
31+
events.set(e.pointerId, []);
32+
}
33+
events.get(e.pointerId).push(e.type);
34+
if (e.type == "pointerdown") {
35+
e.preventDefault();
36+
}
37+
};
38+
const types = ["pointerdown", "pointermove", "pointerup", "pointercancel"];
39+
for (const type of types) {
40+
target.addEventListener(type, listener);
41+
}
42+
t.add_cleanup(() => {
43+
for (const type of types) {
44+
target.removeEventListener(type, listener);
45+
}
46+
});
47+
return events;
48+
}
49+
50+
function checkPointerEvents(events) {
51+
assert_equals(events.size, 2, "Events should be fired for both pointers");
52+
for (const [pointerId, types] of events) {
53+
assert_equals(types[0], "pointerdown",
54+
`The first event of pointer ${pointerId}`);
55+
assert_true(types.includes("pointermove"),
56+
`pointer ${pointerId} should get pointermove`);
57+
assert_equals(types[types.length - 1], "pointerup",
58+
`The last event of pointer ${pointerId}`);
59+
}
60+
}
61+
62+
function addMoves(actions) {
63+
for (let y = 60; y <= 240; y += 30) {
64+
actions.pointerMove(50, y, {origin: "viewport", sourceName: "touch1"})
65+
.pointerMove(250, y, {origin: "viewport", sourceName: "touch2"})
66+
.addTick();
67+
}
68+
return actions;
69+
}
70+
71+
promise_test(async t => {
72+
const events = recordPointerEvents(t);
73+
const actions = new test_driver.Actions()
74+
.addPointer("touch1", "touch")
75+
.addPointer("touch2", "touch")
76+
.pointerMove(50, 30, {origin: "viewport", sourceName: "touch1"})
77+
.pointerDown({sourceName: "touch1"})
78+
.addTick()
79+
.pointerMove(250, 30, {origin: "viewport", sourceName: "touch2"})
80+
.pointerDown({sourceName: "touch2"})
81+
.addTick();
82+
await addMoves(actions)
83+
.pointerUp({sourceName: "touch1"})
84+
.pointerUp({sourceName: "touch2"})
85+
.send();
86+
checkPointerEvents(events);
87+
}, "Two touches which start one after the other and move together");
88+
89+
promise_test(async t => {
90+
const events = recordPointerEvents(t);
91+
const actions = new test_driver.Actions()
92+
.addPointer("touch1", "touch")
93+
.addPointer("touch2", "touch")
94+
.pointerMove(50, 30, {origin: "viewport", sourceName: "touch1"})
95+
.pointerMove(250, 30, {origin: "viewport", sourceName: "touch2"})
96+
.addTick()
97+
.pointerDown({sourceName: "touch1"})
98+
.pointerDown({sourceName: "touch2"})
99+
.addTick();
100+
await addMoves(actions)
101+
.pointerUp({sourceName: "touch1"})
102+
.pointerUp({sourceName: "touch2"})
103+
.send();
104+
checkPointerEvents(events);
105+
}, "Two touches which start at the same time and move together");
106+
</script>

0 commit comments

Comments
 (0)