-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1736034 [wpt PR 31268] - Change wpt tests for <meta name=color-sc…
…heme> to not depend on the color-scheme computed value (before whatwg/html#7226), a=testonly Automatic update from web-platform-tests Change wpt tests for <meta name=color-scheme> to not depend on the color-scheme computed value (before whatwg/html#7226) This makes the tests valid both with and without the spec change proposed above. Will send a follow-up PR to test the spec change. This makes the assumption that the initial browser's color-scheme is light, which I think is a reasonable assumption to run these tests under. An alternative would have to allow both "light" and "dark" wherever we check for "normal" now (which loses test coverage in practice), or I could complicate the test to compute the initial color-scheme using an iframe or what not (but that complicates everything more). -- wpt-commits: 705c808e7a972bc3454f1842cd73f1e85ee31818 wpt-pr: 31268
- Loading branch information
1 parent
8977d8a
commit 49ea084
Showing
8 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 22 additions & 2 deletions
24
...tics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
'use strict'; | ||
|
||
function assert_root_color_scheme(expected, description) { | ||
function assert_root_color_scheme(expected_used_scheme, description) { | ||
function get_used_root_color_scheme() { | ||
let light = get_system_color("only light", "CanvasText"); | ||
let dark = get_system_color("only dark", "CanvasText"); | ||
assert_not_equals(light, dark, "CanvasText system color should be different with light and dark color schemes"); | ||
let root = getComputedStyle(document.documentElement).color; | ||
assert_in_array(root, [light, dark], "Root color scheme should be either light or dark, or the text needs to be extended for newer color-schemes"); | ||
return root == light ? "light" : "dark"; | ||
} | ||
|
||
function get_system_color(scheme, color) { | ||
let div = document.createElement("div"); | ||
div.style.color = color; | ||
div.style.colorScheme = scheme; | ||
|
||
document.documentElement.appendChild(div); | ||
let computed = getComputedStyle(div).color; | ||
div.remove(); | ||
return computed; | ||
} | ||
|
||
test(() => { | ||
assert_equals(getComputedStyle(document.documentElement).colorScheme, expected), "Check root element color scheme"; | ||
assert_equals(get_used_root_color_scheme(), expected_used_scheme); | ||
}, description); | ||
} |