Source code

Revision control

Other Tools

1
<!DOCTYPE html>
3
<script type="text/javascript" src="/resources/testharness.js"></script>
4
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
5
6
<script type="text/javascript" src="resources/matchmedia-utils.js"></script>
7
<script>
8
query_should_be_css_parseable("(prefers-color-scheme)");
9
query_should_be_css_parseable("(prefers-color-scheme: no-preference)");
10
query_should_be_css_parseable("(prefers-color-scheme: light)");
11
query_should_be_css_parseable("(prefers-color-scheme: dark)");
12
13
query_should_not_be_css_parseable("(prefers-color-scheme: 0)");
14
query_should_not_be_css_parseable("(prefers-color-scheme: none)");
15
query_should_not_be_css_parseable("(prefers-color-scheme: 10px)");
16
query_should_not_be_css_parseable("(prefers-color-scheme: dark 0)");
17
query_should_not_be_css_parseable("(prefers-color-scheme: dark light)");
18
query_should_not_be_css_parseable("(prefers-color-scheme: light/dark)");
19
20
query_should_be_js_parseable("(prefers-color-scheme)");
21
query_should_be_js_parseable("(prefers-color-scheme: no-preference)");
22
query_should_be_js_parseable("(prefers-color-scheme: light)");
23
query_should_be_js_parseable("(prefers-color-scheme: dark)");
24
25
query_should_not_be_js_parseable("(prefers-color-scheme: 0)");
26
query_should_not_be_js_parseable("(prefers-color-scheme: none)");
27
query_should_not_be_js_parseable("(prefers-color-scheme: 10px)");
28
query_should_not_be_js_parseable("(prefers-color-scheme: dark 0)");
29
query_should_not_be_js_parseable("(prefers-color-scheme: dark light)");
30
query_should_not_be_js_parseable("(prefers-color-scheme: light/dark)");
31
32
test(() => {
33
let booleanContext = window.matchMedia("(prefers-color-scheme)");
34
let noPreference = window.matchMedia("(prefers-color-scheme: no-preference)");
35
assert_equals(booleanContext.matches, !noPreference.matches);
36
}, "Check that no-preference evaluates to false in the boolean context");
37
</script>