Truly independent web browser
LibWeb: Reject pseudo-class suffixes after slotted selectors
Andreas Kling0a9a590329c8
diff --git a/Libraries/LibWeb/Rust/src/css/selector_parser.rs b/Libraries/LibWeb/Rust/src/css/selector_parser.rsindex 3b23fe72e50..fd3644f449b 100644--- a/Libraries/LibWeb/Rust/src/css/selector_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/selector_parser.rs@@ -472,6 +472,12 @@ impl<'a> SelectorParser<'a> {let Some(SimpleSelector::PseudoElement(pseudo_element)) = compound.simple_selectors.first() else {continue;};+ // https://drafts.csswg.org/css-shadow-1/#slotted-pseudo+ // INTEROP: Selectors 4 permits logical and user action pseudo-classes after pseudo-elements, but+ // browsers require these tests inside the ::slotted() argument.+ if pseudo_element.pseudo_element == PseudoElementType::Slotted && compound.simple_selectors.len() > 1 {+ return Err(());+ }// https://drafts.csswg.org/css-pseudo-4/#highlight-selectors// INTEROP: Selectors 4 allows logical combination and user action pseudo-classes after any// pseudo-element, but browsers reject every simple selector after a highlight pseudo-element.diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-slotted.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-slotted.txtindex 08c74c47997..1198d8a1379 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-slotted.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-slotted.txt@@ -2,8 +2,7 @@ Harness status: OKFound 19 tests-14 Pass-5 Fail+19 PassPass "::slotted(bar)" should be a valid selectorPass "::slotted([attr=\"foo\"])" should be a valid selectorPass "::slotted(*)" should be a valid selector@@ -17,9 +16,9 @@ Pass "::slotted" should be an invalid selectorPass "::slotted()" should be an invalid selectorPass "::slotted(0)" should be an invalid selectorPass ":slotted(foo)" should be an invalid selector-Fail "::slotted(foo):first-child" should be an invalid selector-Fail "::slotted(foo):hover" should be an invalid selector-Fail "::slotted(foo):focus" should be an invalid selector-Fail "::slotted(foo):lang(en)" should be an invalid selector-Fail "::slotted(foo):dir(ltr)" should be an invalid selector+Pass "::slotted(foo):first-child" should be an invalid selector+Pass "::slotted(foo):hover" should be an invalid selector+Pass "::slotted(foo):focus" should be an invalid selector+Pass "::slotted(foo):lang(en)" should be an invalid selector+Pass "::slotted(foo):dir(ltr)" should be an invalid selectorPass "::slotted(foo) + ::slotted(bar)" should be an invalid selector\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-state.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-state.txtindex 954a1a7dbf8..f527cda5633 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-state.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-state.txt@@ -2,8 +2,8 @@ Harness status: OKFound 24 tests-19 Pass-5 Fail+20 Pass+4 FailPass ":state(--foo)" should be a valid selectorPass ":state(bar)" should be a valid selectorPass ":state(--)" should be a valid selector@@ -27,4 +27,4 @@ Fail "my-input::after:state(foo)" should be an invalid selectorFail "::part(inner):state(bar)::before:state(foo)" should be an invalid selectorFail "::part(inner):state(bar)::after:state(foo)" should be an invalid selectorFail "my-input::first-letter:state(foo)" should be an invalid selector-Fail "::slotted(foo):state(foo)" should be an invalid selector\ No newline at end of file+Pass "::slotted(foo):state(foo)" should be an invalid selector\ No newline at end of file