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
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Test for Bug 1663731</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 cancelledTouchMove = false;
// Event listeners just for logging/debugging purposes
body.addEventListener("pointerdown", function(e) {
dump(`Got pointerdown, pointer id ${e.pointerId}\n`);
});
body.addEventListener("touchstart", function(e) {
dump(`Got touchstart with ${e.touches.length} touches\n`);
}, {passive: true});
// Event listeners relevant to the test. We want to make sure that even
// though APZ can zoom the page, it does NOT dispatch pointercancel events in
// the scenario where the page calls preventDefault() on the first touchmove
// with two touch points. In other words, if the page chooses to disable
// browser pinch-zooming by preventDefault()'ing the first touchmove for
// the second touch point, then the browser should not dispatch pointercancel
// at all, but keep sending the pointerevents to the content. This is
// similar to what the browser does when zooming is disallowed by
// touch-action:none, for example.
body.addEventListener("pointercancel", function(e) {
dump(`Got pointercancel, pointer id ${e.pointerId}\n`);
ok(false, "Should not get any pointercancel events");
});
body.addEventListener("touchmove", function(e) {
dump(`Got touchmove with ${e.touches.length} touches\n`);
if (e.touches.length > 1) {
dump(`Preventing...\n`);
e.preventDefault();
cancelledTouchMove = true;
}
}, {passive: false});
let touchEndPromise = new Promise(resolve => {
// This listener is just to catch the end of the touch sequence so we can
// end the test at the right time.
body.addEventListener("touchend", function(e) {
dump(`Got touchend with ${e.touches.length} touches\n`);
if (!e.touches.length) {
resolve();
}
});
});
// We can't await this call, because this pinch action doesn't generate a
// APZ:TransformEnd. Instead we await the touchend.
pinchZoomOutWithTouchAtCenter();
await touchEndPromise;
ok(cancelledTouchMove, "Checking that we definitely cancelled the touchmove");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
<style>
body {
height: 5000px;
}
</style>
</head>
<body>
A two-finger pinch action here should send pointer events to content and not do browser zooming.
</body>
</html>
|