1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Test for Bug 1648491</title>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript">
async function test() {
var body = document.body;
var pointersDown = 0;
var pointersUp = 0;
var pointerMoveCount = 0;
body.addEventListener("pointerdown", function(e) {
dump(`Got pointerdown, pointer id ${e.pointerId}\n`);
pointersDown++;
});
body.addEventListener("pointermove", function(e) {
dump(`Got pointermove, pointer id ${e.pointerId}, at ${e.clientX}, ${e.clientY}\n`);
pointerMoveCount++;
});
let pointersUpPromise = new Promise(resolve => {
body.addEventListener("pointercancel", function(e) {
dump(`Got pointercancel, pointer id ${e.pointerId}\n`);
ok(false, "Should not have gotten pointercancel");
pointersUp++;
if (pointersDown == pointersUp) {
// All pointers lifted, let's continue the test
resolve();
}
});
body.addEventListener("pointerup", function(e) {
dump(`Got pointerup, pointer id ${e.pointerId}\n`);
pointersUp++;
if (pointersDown == pointersUp) {
// All pointers lifted, let's continue the test
resolve();
}
});
});
var zoom_in = [
[ { x: 125, y: 175 }, { x: 175, y: 225 } ],
[ { x: 120, y: 150 }, { x: 180, y: 250 } ],
[ { x: 115, y: 125 }, { x: 185, y: 275 } ],
[ { x: 110, y: 100 }, { x: 190, y: 300 } ],
[ { x: 105, y: 75 }, { x: 195, y: 325 } ],
[ { x: 100, y: 50 }, { x: 200, y: 350 } ],
];
var touchIds = [0, 1];
await synthesizeNativeTouchSequences(document.getElementById("target"), zoom_in, null, touchIds);
dump("All touch events synthesized, waiting for final pointerup...\n");
await pointersUpPromise;
// Should get at least one pointermove per pointer, even if the events
// get coalesced somewhere.
is(pointersDown, 2, "Got expected numbers of pointers recorded");
ok(pointerMoveCount >= 2, "Got " + pointerMoveCount + " pointermove events");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
<style>
body {
height: 5000px;
}
#target {
touch-action: pan-x pan-y;
height: 400px;
}
</style>
</head>
<body>
<div id="target" onwheel="return false;">
A two-finger pinch action here should send pointer events to content.
</div>
</body>
</html>
|