Skip to content

Truly independent web browser

LibWeb: Import slotted selector parsing coverage

Andreas Kling7b87b134a03f
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.txt
new file mode 100644
index 00000000000..08c74c47997
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-slotted.txt
@@ -0,0 +1,25 @@
+Harness status: OK
+
+Found 19 tests
+
+14 Pass
+5 Fail
+Pass "::slotted(bar)" should be a valid selector
+Pass "::slotted([attr=\"foo\"])" should be a valid selector
+Pass "::slotted(*)" should be a valid selector
+Pass "::slotted(.class)" should be a valid selector
+Pass "::slotted(:not(foo))" should be a valid selector
+Pass "::slotted(:not(:nth-last-of-type(2)):not([slot=\"foo\"]))" should be a valid selector
+Pass "::slotted(:first-child)" should be a valid selector
+Pass "::slotted(:hover)" should be a valid selector
+Pass "::slotted(:has(:first-child:last-child))" should be a valid selector
+Pass "::slotted" should be an invalid selector
+Pass "::slotted()" should be an invalid selector
+Pass "::slotted(0)" should be an invalid selector
+Pass ":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) + ::slotted(bar)" should be an invalid selector
\ No newline at end of file
diff --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.txt
new file mode 100644
index 00000000000..954a1a7dbf8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/parsing/parse-state.txt
@@ -0,0 +1,30 @@
+Harness status: OK
+
+Found 24 tests
+
+19 Pass
+5 Fail
+Pass ":state(--foo)" should be a valid selector
+Pass ":state(bar)" should be a valid selector
+Pass ":state(--)" should be a valid selector
+Pass ":state(--0)" should be a valid selector
+Pass ":host(:state(--foo))" should be a valid selector
+Pass "my-input[type=\"foo\"]:state(checked)" should be a valid selector
+Pass "my-input[type=\"foo\"]:state(--0)::before" should be a valid selector
+Pass "my-input[type=\"foo\"]:state(--0)::part(inner)" should be a valid selector
+Pass "my-input[type=\"foo\"]:state(--0)::part(inner):state(bar)" should be a valid selector
+Pass "::part(inner):state(bar)::before" should be a valid selector
+Pass "::part(inner):state(bar)::after" should be a valid selector
+Pass ":state" should be an invalid selector
+Pass ":state(" should be an invalid selector
+Pass ":state()" should be an invalid selector
+Pass ":state(0)" should be an invalid selector
+Pass ":state(0rem)" should be an invalid selector
+Pass ":state(url())" should be an invalid selector
+Pass ":state(foo(1))" should be an invalid selector
+Pass ":state(:host)" should be an invalid selector
+Fail "my-input::after:state(foo)" should be an invalid selector
+Fail "::part(inner):state(bar)::before:state(foo)" should be an invalid selector
+Fail "::part(inner):state(bar)::after:state(foo)" should be an invalid selector
+Fail "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
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/selectors/parsing/parse-slotted.html b/Tests/LibWeb/Text/input/wpt-import/css/selectors/parsing/parse-slotted.html
new file mode 100644
index 00000000000..a51b64d914e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/selectors/parsing/parse-slotted.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<meta charset="utf-8" />
+<title>CSS Selectors: slotted pseudo selectors</title>
+<link rel="help" href="https://drafts.csswg.org/css-shadow/#slotted-pseudo" />
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../css/support/parsing-testcommon.js"></script>
+<script>
+ test_valid_selector("::slotted(bar)");
+ test_valid_selector('::slotted([attr="foo"])');
+ test_valid_selector("::slotted(*)");
+ test_valid_selector("::slotted(.class)");
+ test_valid_selector("::slotted(:not(foo))");
+ test_valid_selector('::slotted(:not(:nth-last-of-type(2)):not([slot="foo"]))');
+ test_valid_selector("::slotted(:first-child)");
+ test_valid_selector("::slotted(:hover)");
+ test_valid_selector("::slotted(:has(:first-child:last-child))");
+ test_invalid_selector("::slotted");
+ test_invalid_selector("::slotted()");
+ test_invalid_selector("::slotted(0)");
+ test_invalid_selector(":slotted(foo)");
+ test_invalid_selector("::slotted(foo):first-child");
+ test_invalid_selector("::slotted(foo):hover");
+ test_invalid_selector("::slotted(foo):focus");
+ test_invalid_selector("::slotted(foo):lang(en)");
+ test_invalid_selector("::slotted(foo):dir(ltr)");
+ test_invalid_selector('::slotted(foo) + ::slotted(bar)');
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/selectors/parsing/parse-state.html b/Tests/LibWeb/Text/input/wpt-import/css/selectors/parsing/parse-state.html
new file mode 100644
index 00000000000..5181a337eda
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/selectors/parsing/parse-state.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<meta charset="utf-8" />
+<title>CSS Selectors: custom state pseudo selectors</title>
+<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/8213" />
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../css/support/parsing-testcommon.js"></script>
+<script>
+ test_valid_selector(":state(--foo)");
+ test_valid_selector(":state(bar)");
+ test_valid_selector(":state(--)");
+ test_valid_selector(":state(--0)");
+ test_valid_selector(":host(:state(--foo))");
+ test_valid_selector('my-input[type="foo"]:state(checked)');
+ test_valid_selector('my-input[type="foo"]:state(--0)::before');
+ test_valid_selector('my-input[type="foo"]:state(--0)::part(inner)');
+ test_valid_selector(
+ 'my-input[type="foo"]:state(--0)::part(inner):state(bar)',
+ );
+ test_valid_selector('::part(inner):state(bar)::before');
+ test_valid_selector('::part(inner):state(bar)::after');
+ test_invalid_selector(":state");
+ test_invalid_selector(":state(");
+ test_invalid_selector(":state()");
+ test_invalid_selector(":state(0)");
+ test_invalid_selector(":state(0rem)");
+ test_invalid_selector(":state(url())");
+ test_invalid_selector(":state(foo(1))");
+ test_invalid_selector(":state(:host)");
+ test_invalid_selector("my-input::after:state(foo)");
+ test_invalid_selector('::part(inner):state(bar)::before:state(foo)');
+ test_invalid_selector('::part(inner):state(bar)::after:state(foo)');
+ test_invalid_selector("my-input::first-letter:state(foo)");
+ test_invalid_selector('::slotted(foo):state(foo)');
+</script>