-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathmedia-loading-state.sub.html
More file actions
60 lines (58 loc) · 2.19 KB
/
media-loading-state.sub.html
File metadata and controls
60 lines (58 loc) · 2.19 KB
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
<!DOCTYPE html>
<meta name="timeout" content="long" />
<title>Media Loading State: the :buffering and :stalled pseudo-classes</title>
<link
rel="help"
href="https://drafts.csswg.org/selectors/#media-loading-state"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<video width="300" height="300" muted loop controls></video>
<script type="module">
test((t) => {
for (const pseudo of [":buffering", ":stalled"]) {
try {
document.querySelector(`.not-a-thing${pseudo}`);
} catch (e) {
assert_unreached(`${pseudo} is not supported`);
}
}
}, "Test :pseudo-class syntax is supported without throwing a SyntaxError");
promise_test(async (t) => {
assert_implements(CSS.supports("selector(:stalled)"), ":stalled is not supported");
const key = "{{uuid()}}";
const video = document.querySelector("video");
await new Promise((r) => {
video.addEventListener("stalled", r, { once: true });
video.src = `support/stall-resume.py?key=${key}`;
});
const promise = video.play();
assert_true(video.matches(":stalled"), ":stalled matches");
video.src = "";
assert_false(video.matches(":stalled"), ":stalled stops matching");
// Wait for the video to abort trying to play
try {
await promise;
} catch (err) {}
}, "Test :stalled pseudo-class");
promise_test(async (t) => {
assert_implements(CSS.supports("selector(:buffering)"), ":buffering is not supported");
const key = "{{uuid()}}";
const video = document.querySelector("video");
await new Promise((r) => {
video.addEventListener("stalled", r, { once: true });
video.src = `support/stall-resume.py?key=${key}`;
});
video.currentTime = 10;
const promise = video.play();
assert_true(video.matches(":buffering"), ":buffering matches");
video.src = "";
assert_false(video.matches(":buffering"), ":buffering stops matching");
// Wait for the video to abort trying to play
try {
await promise;
} catch (err) {}
}, "Test :buffering pseudo-class");
</script>
</body>