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
|
<!doctype HTML>
<html>
<meta charset="utf8">
<title>Content Visibility: ContentVisibilityAutoStateChange event.</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-contain/#content-visibility">
<meta name="timeout" content="long">
<meta name="assert" content="ContentVisibilityAutoStateChange fires when things enter/exit viewport">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/utils.js"></script>
<script src="/scroll-to-text-fragment/stash.js"></script>
<style>
.spacer {
height: 3000px;
}
.auto { content-visibility: auto; }
</style>
<div id=upper></div>
<div class=spacer></div>
<div id=middle></div>
<div class=spacer></div>
<div id=lower></div>
<script>
promise_test(t => new Promise(async (resolve, reject) => {
let shouldSkip = false;
const listener = (e) => {
if (!e.skipped)
resolve();
};
upper.addEventListener("contentvisibilityautostatechange", listener);
t.add_cleanup(() => upper.removeEventListener("contentvisibilityautostatechange", listener));
upper.classList.add("auto");
}), "ContentVisibilityAutoStateChange fires when relevant element gains `content-visibility:auto`");
promise_test(t => new Promise(async (resolve, reject) => {
let shouldSkip = false;
const listener = (e) => {
if (e.skipped)
resolve();
else
reject();
};
lower.addEventListener("contentvisibilityautostatechange", listener);
t.add_cleanup(() => lower.removeEventListener("contentvisibilityautostatechange", listener));
lower.classList.add("auto");
}), "ContentVisibilityAutoStateChange fires when not relevant element gains `content-visibility:auto`");
promise_test(t => new Promise(async (resolve, reject) => {
await new Promise((waited, _) => {
requestAnimationFrame(() => requestAnimationFrame(waited));
});
const listener = (e) => {
if (e.skipped)
resolve();
};
upper.addEventListener("contentvisibilityautostatechange", listener);
t.add_cleanup(() => upper.removeEventListener("contentvisibilityautostatechange", listener));
requestAnimationFrame(() => requestAnimationFrame(() => {
middle.scrollIntoView();
}));
}), "ContentVisibilityAutoStateChange fires when skipped");
promise_test(t => new Promise(async (resolve, reject) => {
await new Promise((waited, _) => {
requestAnimationFrame(() => requestAnimationFrame(waited));
});
const listener = (e) => {
if (!e.skipped)
resolve();
else
reject();
}
lower.addEventListener("contentvisibilityautostatechange", listener);
t.add_cleanup(() => {
lower.removeEventListener("contentvisibilityautostatechange", listener);
});
requestAnimationFrame(() => requestAnimationFrame(() => {
lower.scrollIntoView();
}));
}), "ContentVisibilityAutoStateChange fires when not skipped");
</script>
|