blob: 95447fbd12ea2a0c149d196a3ef0fe681ea03131 (
plain)
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
|
<!DOCTYPE HTML>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="scroll_support.js"></script>
<style>
#rootDiv {
width: 500px;
height: 500px;
}
#targetDiv {
width: 200px;
height: 200px;
overflow: scroll;
}
#innerDiv {
width: 500px;
height: 4000px;
}
</style>
<body style="margin:0" onload=runTest()>
</body>
<script>
let scrollend_arrived = false;
async function setupHtmlAndScrollAndRemoveElement(element_to_remove_id) {
document.body.innerHTML=`
<div id="rootDiv">
<div id="targetDiv">
<div id="innerDiv">
</div>
</div>
</div>
`;
await waitForCompositorCommit();
const target_div = document.getElementById('targetDiv');
const element_to_remove = document.getElementById(element_to_remove_id);
let reached_half_scroll = false;
scrollend_arrived = false;
target_div.addEventListener("scrollend", () => {
scrollend_arrived = true;
});
target_div.onscroll = () => {
// Remove the element after reached half of the scroll offset,
if(target_div.scrollTop >= 1000) {
reached_half_scroll = true;
element_to_remove.remove();
}
};
target_div.scrollTo({top:2000, left:0, behavior:"smooth"});
await waitFor(() => {return reached_half_scroll; },
"target_div never reached scroll offset of 1000");
await waitForCompositorCommit();
}
function runTest() {
promise_test (async (t) => {
await setupHtmlAndScrollAndRemoveElement("rootDiv");
await conditionHolds(() => { return !scrollend_arrived; });
}, "No scrollend is received after removing parent div");
promise_test (async (t) => {
await setupHtmlAndScrollAndRemoveElement("targetDiv");
await conditionHolds(() => { return !scrollend_arrived; });
}, "No scrollend is received after removing scrolling element");
promise_test (async (t) => {
await setupHtmlAndScrollAndRemoveElement("innerDiv");
await waitFor(() => { return scrollend_arrived; },
'target_div did not receive scrollend event after vertical scroll.');
}, "scrollend is received after removing descendant div");
}
</script>
|