From 7eab60695b466d1f26e659dd45ea8dc1db377419 Mon Sep 17 00:00:00 2001 From: Anders Hartvoll Ruud Date: Fri, 15 Nov 2024 17:13:05 +0000 Subject: [PATCH] Bug 1930968 [wpt PR 49150] - Remove special :scope matching code in MatchForRelation, a=testonly Automatic update from web-platform-tests Remove special :scope matching code in MatchForRelation This special path causes :scope selectors to incorrectly match ':scope *' selectors in shadow roots, when it actually should match nothing [1]. The provided test scope-pseudo-in-shadow.html is passing in Firefox and Safari. The existing WPT scope-selector.html (all browsers currently passing) cover querySelector[All] cases well for shadow roots, document, and other DocumentFragments. There should be no behavior change there. Fixed: 378698644 [1] https://github.com/w3c/csswg-drafts/issues/11188 [2] https://github.com/w3c/csswg-drafts/issues/7261 Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6011808 Reviewed-by: Rune Lillesveen Commit-Queue: Anders Hartvoll Ruud Cr-Commit-Position: refs/heads/main@{#1382339} -- wpt-commits: 7b7e2451a431d0cc68e4e5a96d19a71675dd782d wpt-pr: 49150 --- .../css-scoping/scope-pseudo-in-shadow.html | 27 +++++++++++++++++++ .../prefetch/document-rules.https.html | 19 ------------- 2 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 testing/web-platform/tests/css/css-scoping/scope-pseudo-in-shadow.html diff --git a/testing/web-platform/tests/css/css-scoping/scope-pseudo-in-shadow.html b/testing/web-platform/tests/css/css-scoping/scope-pseudo-in-shadow.html new file mode 100644 index 0000000000000..ca8720d975f1c --- /dev/null +++ b/testing/web-platform/tests/css/css-scoping/scope-pseudo-in-shadow.html @@ -0,0 +1,27 @@ + +:scope pseudo does not match in shadow root + + + + +
+ diff --git a/testing/web-platform/tests/speculation-rules/prefetch/document-rules.https.html b/testing/web-platform/tests/speculation-rules/prefetch/document-rules.https.html index 805f1cfbc36bf..ae75ec94036f4 100644 --- a/testing/web-platform/tests/speculation-rules/prefetch/document-rules.https.html +++ b/testing/web-platform/tests/speculation-rules/prefetch/document-rules.https.html @@ -18,7 +18,6 @@ - @@ -183,24 +182,6 @@ assert_equals(await isUrlPrefetched(url_2), 0); }, 'test selector_matches with :root'); - // 'selector_matches' should use the shadowRoot as the scoping root when - // matching links inside a shadow tree. - subsetTestByKey('selectorMatchesInShadowTree', promise_test, async t => { - insertDocumentRule({ selector_matches: ':scope a.important-link' }); - - // Create shadow root. - const shadowHost = document.createElement('div'); - document.body.appendChild(shadowHost); - const shadowRoot = shadowHost.attachShadow({ mode: 'open' }); - - const url = getPrefetchUrl(); - const link = addLink(url, shadowRoot); - link.className = 'important-link'; - await new Promise(resolve => t.step_timeout(resolve, 2000)); - - assert_equals(await isUrlPrefetched(url), 1); - }, 'test selector_matches with link inside shadow tree'); - subsetTestByKey('selectorMatchesDisplayNone', promise_test, async t => { const style = document.createElement('style'); style.innerText = ".important-section { display: none; }";