commit c725a3a03ad50a6a9c4cb29b7ee37f3a6ce94071
parent 63edb040bf3f3db3f0137e3f807b71ce57c5a465
Author: Rune Lillesveen <futhark@chromium.org>
Date: Thu, 9 Oct 2025 20:37:18 +0000
Bug 1992399 [wpt PR 55225] - Don't allow anchor functions in registered custom properties, a=testonly
Automatic update from web-platform-tests
Don't allow anchor functions in registered custom properties
Anchor functions are only allowed for a selected set of standard
properties. We allowed parsing anchor functions for registered
length-percentages which hit some DCHECKs.
Bug: 369219149
Change-Id: Ie94a1e2e2123ec2fa589e430238705efd9abae21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7003392
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1524686}
--
wpt-commits: 84f3696fc117b412a475a3fb08a27fa756b86962
wpt-pr: 55225
Diffstat:
1 file changed, 49 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/css/css-anchor-position/registered-custom-property-anchor.html b/testing/web-platform/tests/css/css-anchor-position/registered-custom-property-anchor.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: anchor() and anchor-size() not valid in registered custom properties</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-pos">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ @property --length {
+ syntax: "<length>";
+ inherits: false;
+ initial-value: 0px;
+ }
+ @property --length-percentage {
+ syntax: "<length-percentage>";
+ inherits: false;
+ initial-value: 0px;
+ }
+ @property --number {
+ syntax: "<number>";
+ inherits: false;
+ initial-value: 0;
+ }
+ #anchor {
+ --length: anchor(--foo bottom, 5px);
+ --length-percentage: anchor(--foo bottom, 10%);
+ --number: sign(anchor(--foo bottom, 100px));
+ }
+ #anchor-size {
+ --length: anchor-size(--foo block, 7px);
+ --length-percentage: anchor-size(--foo block, 20%);
+ --number: sign(anchor-size(--foo block, 100px));
+ }
+</style>
+<div id="anchor"></div>
+<div id="anchor_size"></div>
+<script>
+ test(() => {
+ const style = getComputedStyle(anchor);
+ assert_equals(style.getPropertyValue("--length"), "0px");
+ assert_equals(style.getPropertyValue("--length-percentage"), "0px");
+ assert_equals(style.getPropertyValue("--number"), "0");
+ }, "anchor() functions are not allowed in registered custom properties accepting <length> or <length-percentage>");
+
+ test(() => {
+ const style = getComputedStyle(anchor_size);
+ assert_equals(style.getPropertyValue("--length"), "0px");
+ assert_equals(style.getPropertyValue("--length-percentage"), "0px");
+ assert_equals(style.getPropertyValue("--number"), "0");
+ }, "anchor-size() using fallback value for registered custom properties accepting <length> or <length-percentage>");
+</script>