commit 23dca4da7ba40a1bdd605dc776c77ffcf8d5a3e4
parent c517f87e676fed6f8ec965a1b0db0e54e570737f
Author: Daniil Sakhapov <sakhapov@chromium.org>
Date: Mon, 8 Dec 2025 12:28:24 +0000
Bug 2004430 [wpt PR 56524] - Fix counter() and counters() in alt content, a=testonly
Automatic update from web-platform-tests
Fix counter() and counters() in alt content
Before that, the value of the counter text were saved in content data,
but content data was shared between the same pseudo-elements. This CL
clones content data so that each pseudo-element has its own copy.
Also, this CL only updates the counter text when attaching layout tree
from the root, as we do for regular counters.
Fixed: 463528045
Change-Id: I564eb5e086a319b77d28338950b305d24db720c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7208887
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Daniil Sakhapov <sakhapov@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1554610}
--
wpt-commits: 0fb4fb09b096dd4edb75e70ca44968660c98cf38
wpt-pr: 56524
Diffstat:
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/accname/name/comp_name_from_content.html b/testing/web-platform/tests/accname/name/comp_name_from_content.html
@@ -28,6 +28,16 @@
counter-set: cnt 5051;
content: "" / counter(cnt);
}
+ .multi-alt-counter {
+ counter-reset: multi_alt 10;
+ }
+ .multi-alt-counter span::before {
+ counter-increment: multi_alt 1;
+ content: "" / counter(multi_alt) " ";
+ }
+ .multi-alt-counter span:nth-child(2n)::before {
+ counter-increment: multi_alt 2;
+ }
.simple-before::before {
content: " before "; /* [sic] leading and trailing space */
margin:0 0.1em;
@@ -113,6 +123,12 @@
<a href="#" data-expectedlabel="5051 label" data-testname="link with alt counter on ::before" class="ex alt-counter">label</a><br>
<br>
+<h1>multiple alt counters with varying increments</h1>
+<button data-expectedlabel="11 alpha 13 beta 14 gamma" data-testname="button with multiple alt counters and counter increments" class="ex multi-alt-counter"><span>alpha</span> <span>beta</span> <span>gamma</span></button><br>
+<h3 data-expectedlabel="11 alpha 13 beta 14 gamma" data-testname="heading with multiple alt counters and counter increments" class="ex multi-alt-counter"><span>alpha</span> <span>beta</span> <span>gamma</span></h3>
+<a href="#" data-expectedlabel="11 alpha 13 beta 14 gamma" data-testname="link with multiple alt counters and counter increments" class="ex multi-alt-counter"><span>alpha</span> <span>beta</span> <span>gamma</span></a><br>
+<br>
+
<h1>simple with ::before</h1>
<button data-expectedlabel="before label" data-testname="button name from content with ::before" class="ex simple-before">label</button><br>
<h3 data-expectedlabel="before label" data-testname="heading name from content with ::before" class="ex simple-before">label</h3>
diff --git a/testing/web-platform/tests/accname/name/comp_name_from_content_alt_counter_multi_instance.html b/testing/web-platform/tests/accname/name/comp_name_from_content_alt_counter_multi_instance.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<title>Name Comp: Alt Counter Content Isolation</title>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="/resources/wpt_test_util.js"></script>
+<script src="/wai-aria/scripts/aria-utils.js"></script>
+<style>
+:root {
+ counter-reset: seq 0;
+}
+
+.alt-counter::before {
+ counter-increment: seq;
+ content: "" / counter(seq);
+}
+</style>
+
+<p>Ensures that CSS alt counter text stored in ::before content remains isolated per element even when styles are shared.</p>
+
+<div id="tests">
+ <button data-expectedlabel="1 label" data-testname="first button" class="ex alt-counter">label</button><br>
+ <h3 data-expectedlabel="2 label" data-testname="heading" class="ex alt-counter">label</h3>
+ <a href="#" data-expectedlabel="3 label" data-testname="link" class="ex alt-counter">label</a><br>
+</div>
+
+<script>
+AriaUtils.verifyLabelsBySelector(".ex");
+</script>