Truly independent web browser
LibWeb: Reject simple selectors after highlight pseudo-elements
Andreas Klinge5003975c369
diff --git a/Libraries/LibWeb/Rust/src/css/selector_parser.rs b/Libraries/LibWeb/Rust/src/css/selector_parser.rsindex 7642f422984..79abd08af0a 100644--- a/Libraries/LibWeb/Rust/src/css/selector_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/selector_parser.rs@@ -472,6 +472,17 @@ impl<'a> SelectorParser<'a> {let Some(SimpleSelector::PseudoElement(pseudo_element)) = compound.simple_selectors.first() else {continue;};+ // 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.+ // ::search-text is checked above, as it allows :current.+ if matches!(+ pseudo_element.pseudo_element,+ PseudoElementType::Selection | PseudoElementType::SpellingError+ ) && compound.simple_selectors.len() > 1+ {+ return Err(());+ }// https://drafts.csswg.org/css-view-transitions-1/#pseudo-root// If a descendant pseudo of a pseudo-element root has no other siblings, then :only-child matches that// pseudo.diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/highlight-pseudos.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/highlight-pseudos.txtindex 007c01f57d8..ca26b7c075a 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/highlight-pseudos.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/highlight-pseudos.txt@@ -2,17 +2,17 @@ Harness status: OKFound 40 tests-28 Pass-12 Fail+32 Pass+8 FailPass "::selection" should be a valid selectorPass ".a::selection" should be a valid selectorPass "div ::selection" should be a valid selectorPass "::part(my-part)::selection" should be a valid selectorPass "::before::selection" should be an invalid selector-Fail "::selection.a" should be an invalid selector+Pass "::selection.a" should be an invalid selectorPass "::selection div" should be an invalid selectorPass "::selection::after" should be an invalid selector-Fail "::selection:hover" should be an invalid selector+Pass "::selection:hover" should be an invalid selectorPass ":not(::selection)" should be an invalid selectorFail "::target-text" should be a valid selectorFail ".a::target-text" should be a valid selector@@ -29,10 +29,10 @@ Pass ".a::spelling-error" should be a valid selectorPass "div ::spelling-error" should be a valid selectorPass "::part(my-part)::spelling-error" should be a valid selectorPass "::before::spelling-error" should be an invalid selector-Fail "::spelling-error.a" should be an invalid selector+Pass "::spelling-error.a" should be an invalid selectorPass "::spelling-error div" should be an invalid selectorPass "::spelling-error::after" should be an invalid selector-Fail "::spelling-error:hover" should be an invalid selector+Pass "::spelling-error:hover" should be an invalid selectorPass ":not(::spelling-error)" should be an invalid selectorFail "::grammar-error" should be a valid selectorFail ".a::grammar-error" should be a valid selector