Make color-scheme meta affect all normal schemes
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.
There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.
We now align with Gecko and Safari.
See the whatwg issue[1] for a discussion.
[1] https://github.com/whatwg/html/issues/7213
Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560051
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#987452}
diff --git a/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-normal-descendant-change.html b/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-normal-descendant-change.html
new file mode 100644
index 0000000..136f4c3
--- /dev/null
+++ b/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-normal-descendant-change.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>Change color-scheme meta tag affecting normal descendant</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<meta id="meta" name="color-scheme" content="dark">
+<div style="color-scheme: dark; color: CanvasText" id="dark">
+ <div style="color-scheme: normal; color: CanvasText" id="normal"></div>
+</div>
+<script>
+ test(() => {
+ assert_equals(getComputedStyle(dark).color, getComputedStyle(normal).color);
+ }, "Normal initially dark");
+
+ meta.content = "light";
+
+ test(() => {
+ assert_not_equals(getComputedStyle(dark).color, getComputedStyle(normal).color);
+ }, "Normal should change to light from page color schemes");
+</script>