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
|
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
</head>
<body>
<div style="height: 200vh;"></div>
</body>
<script type="application/javascript">
async function test() {
const moveDistance = 10;
// Start dragging the vertical scrollbar thumb.
const startPoint = await scrollbarDragStart(window, 1);
await promiseNativeMouseEventWithAPZ({
target: window,
offsetX: startPoint.x,
offsetY: startPoint.y,
type: "mousemove",
});
await promiseNativeMouseEventWithAPZ({
target: window,
offsetX: startPoint.x,
offsetY: startPoint.y,
type: "mousedown",
});
// Move the thumb and wait for a scroll event triggered by the movement.
let scrollEventPromise = waitForScrollEvent(window);
await promiseNativeMouseEventWithAPZ({
target: window,
offsetX: startPoint.x,
offsetY: startPoint.y + moveDistance,
type: "mousemove",
});
await scrollEventPromise;
let scrollPosition = window.scrollY;
// Append an element to the scroll container to expand the scroll range.
const content = document.createElement("div");
content.style.height = "200vh";
document.body.appendChild(content);
// flush the above change.
document.documentElement.getBoundingClientRect();
// Make sure the change has been reflected into APZ.
await promiseApzFlushedRepaints();
// Move the thumb again.
scrollEventPromise = waitForScrollEvent(window);
await promiseNativeMouseEventWithAPZ({
target: window,
offsetX: startPoint.x,
offsetY: startPoint.y + moveDistance * 2,
type: "mousemove",
});
await scrollEventPromise;
ok(window.scrollY <= scrollPosition * 2,
`The scroll position ${window.scrollY} should be less than ${scrollPosition*2}`);
await promiseNativeMouseEventWithAPZ({
target: window,
offsetX: startPoint.x,
offsetY: startPoint.y + moveDistance * 2,
type: "mouseup",
});
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>
</html>
|