-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathsound-state.html
More file actions
47 lines (45 loc) · 1.71 KB
/
sound-state.html
File metadata and controls
47 lines (45 loc) · 1.71 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
<!DOCTYPE html>
<title>Sound State: the :muted and :volume-locked pseudo-classes</title>
<link
rel="help"
href="https://un5n798jx6qx6j0rmf2verhh.julianrbryant.com/selectors/#sound-state"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<body>
<video width="300" height="300" loop></video>
<script type="module">
// Unfortunately, we can't test the volume-locked state because it's not
// possible to lock the volume of a video element with JS.
test((t) => {
for (const pseudo of [":muted", ":volume-locked"]) {
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(:muted)"), ":muted is not supported");
assert_equals(
document.querySelector("video:muted"),
null,
"must know :muted"
);
const video = document.querySelector("video");
await new Promise((r) => {
video.addEventListener("canplay", r, { once: true });
video.src = getVideoURI("/media/counting");
});
video.muted = false;
assert_false(video.muted, "video is unmuted");
assert_equals(document.querySelector("video:muted"), null);
assert_equals(document.querySelector("video:not(:muted)"), video);
video.muted = true;
assert_equals(document.querySelector("video:muted"), video);
assert_equals(document.querySelector("video:not(:muted)"), null);
}, "Test :muted pseudo-class");
</script>
</body>