mirror of
https://github.com/servo/servo.git
synced 2025-08-26 23:58:20 +01:00
Update web-platform-tests to revision 2d42384cf21efd71843295d319c1bab85b3acf4a
This commit is contained in:
parent
f2b224d610
commit
e851ef0cd2
1014 changed files with 5653 additions and 1590 deletions
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="help" href="https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme" />
|
||||
<script type="text/javascript" src="/resources/testharness.js"></script>
|
||||
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
|
||||
<style id="testStyle"> </style>
|
||||
<script>
|
||||
var sheet = testStyle.sheet;
|
||||
|
||||
function query_is_parseable(query) {
|
||||
try {
|
||||
sheet.insertRule("@media " + query + "{}", 0);
|
||||
return sheet.cssRules.length == 1 &&
|
||||
sheet.cssRules[0].media.mediaText != "not all";
|
||||
} finally {
|
||||
while (sheet.cssRules.length)
|
||||
sheet.deleteRule(0);
|
||||
}
|
||||
}
|
||||
|
||||
function query_should_be_parseable(query) {
|
||||
test(() => {
|
||||
assert_true(query_is_parseable(query));
|
||||
}, "Should be parseable: '" + query + "'");
|
||||
}
|
||||
|
||||
function query_should_not_be_parseable(query) {
|
||||
test(() => {
|
||||
assert_false(query_is_parseable(query));
|
||||
}, "Should not be parseable: '" + query + "'");
|
||||
}
|
||||
|
||||
query_should_be_parseable("(prefers-color-scheme)");
|
||||
query_should_be_parseable("(prefers-color-scheme: no-preference)");
|
||||
query_should_be_parseable("(prefers-color-scheme: light)");
|
||||
query_should_be_parseable("(prefers-color-scheme: dark)");
|
||||
|
||||
query_should_not_be_parseable("(prefers-color-scheme: 0)");
|
||||
query_should_not_be_parseable("(prefers-color-scheme: none)");
|
||||
query_should_not_be_parseable("(prefers-color-scheme: 10px)");
|
||||
query_should_not_be_parseable("(prefers-color-scheme: dark 0)");
|
||||
query_should_not_be_parseable("(prefers-color-scheme: dark light)");
|
||||
query_should_not_be_parseable("(prefers-color-scheme: light/dark)");
|
||||
|
||||
test(() => {
|
||||
let booleanContext = window.matchMedia("(prefers-color-scheme)");
|
||||
let noPreference = window.matchMedia("(prefers-color-scheme: no-preference)");
|
||||
assert_equals(booleanContext.matches, !noPreference.matches);
|
||||
}, "Check that no-preference evaluates to false in the boolean context");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue