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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
html, body { margin: 0; }
#scrollable {
height: 50vh;
width: 50vw;
background: yellow;
overflow: scroll;
}
#scrollabletarget {
height: 200vh;
width: 200vh;
background: green;
}
#scrollabletarget:active {
background: red;
}
#notscrollable {
height: 50vh;
width: 50vw;
background: green;
}
#notscrollable:active {
background: red;
}
</style>
</head>
<body>
<div id="scrollable">
<div id="scrollabletarget">
</div>
</div>
<div id="notscrollable">
</div>
</body>
<script>
const searchParams = new URLSearchParams(location.search);
async function test() {
let activeQuery = null;
let targetElem = null;
switch (searchParams.get("scrollable")) {
case "true":
activeQuery = "#scrollabletarget:active"
targetElem = scrollabletarget
break;
case "false":
activeQuery = "#notscrollable:active"
targetElem = notscrollable;
break;
default:
ok(false, "Unsupported scrollable value: " + searchParams.get("scrollable"));
break;
}
// Create a promise for each of the expected mouse events that are
// synthesized for a tap gesture
let mouseEventPromises = [
promiseOneEvent(targetElem, "mousemove"),
promiseOneEvent(targetElem, "mousedown"),
promiseOneEvent(targetElem, "mouseup"),
promiseOneEvent(targetElem, "click"),
];
// Perform a tap gesture
await synthesizeNativeTap(targetElem, 50, 50);
// Set a timeout that will fail the test if the synthesized events
// are not immediately dispatched.
let failTimeout = setTimeout(() => {
ok(false, "The synthesized mouse events should be emitted in a timely manner");
}, 45000);
// The value of ui.touch_activation.duration_ms should be set to
// a large value. If we did not delay sending the synthesized
// mouse events, this test will not timeout.
await Promise.all(mouseEventPromises);
clearTimeout(failTimeout);
isnot(document.querySelector(activeQuery), null,
"Target element should still be active due to the large activation duration");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</head>
</html>
|