commit e70bea9e542268197c1e6dee93c75c4d8f668744
parent 9cf5d6748d8991c3249ea07a9aee8aabd8dc4e9c
Author: Rune Lillesveen <futhark@chromium.org>
Date: Fri, 7 Nov 2025 08:56:46 +0000
Bug 1998546 [wpt PR 55879] - Add tests for matching non-rendered elements in svg <use> trees, a=testonly
Automatic update from web-platform-tests
Add tests for matching non-rendered elements in svg <use> trees
Even if some elements like <defs> are not rendered, we should be able to
match them with structural selectors like sibling selectors and :has().
These tests are currently failing in Blink because we do not clone
all elements into the <use> tree, contrary to what the SVG2 spec says.
Bug: 386610909
Change-Id: Ia1d330b09cba492b42510073564e95fdbb1e4d7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7122023
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1540684}
--
wpt-commits: 1682bdf5b456d950fab983a1f51e6d36e39392fb
wpt-pr: 55879
Diffstat:
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/svg/styling/use-element-non-rendered-has-selector.html b/testing/web-platform/tests/svg/styling/use-element-non-rendered-has-selector.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<title>SVG Test: CSS selector matching non-rendered descendant with :has() in <use> element tree</title>
+<link rel="help" href="https://svgwg.org/svg2-draft/struct.html#UseElement">
+<link rel="match" href="use-element-selector-ref.html">
+<style>
+ #rect:has(defs) { fill: green; }
+</style>
+<svg>
+ <use id="use_elm" xlink:href="#group" />
+ <defs>
+ <g id="group">
+ <rect id="rect" width="100" height="100">
+ <defs></defs>
+ </rect>
+ </g>
+ </defs>
+</svg>
diff --git a/testing/web-platform/tests/svg/styling/use-element-non-rendered-sibling-selector.html b/testing/web-platform/tests/svg/styling/use-element-non-rendered-sibling-selector.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<title>SVG Test: CSS selector matching non-rendered sibling in <use> element tree</title>
+<link rel="help" href="https://svgwg.org/svg2-draft/struct.html#UseElement">
+<link rel="match" href="use-element-selector-ref.html">
+<style>
+ defs + #rect { fill: green; }
+</style>
+<svg>
+ <use id="use_elm" xlink:href="#group" />
+ <defs>
+ <g id="group">
+ <defs></defs>
+ <rect id="rect" width="100" height="100"></rect>
+ </g>
+ </defs>
+</svg>