diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js')
-rw-r--r-- | testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js new file mode 100644 index 0000000000..74cbf895ce --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js @@ -0,0 +1,28 @@ +'use strict'; + +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(get_used_root_color_scheme(), expected_used_scheme); + assert_equals(getComputedStyle(document.documentElement).colorScheme, "normal", "Root element's color-scheme should be 'normal'"); + }, description); +} |