Skip to content

Truly independent web browser

LibWeb: Import selector support validation coverage

Andreas Klingc804c5d67fed
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/js/CSS-supports-L4.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/js/CSS-supports-L4.txt
new file mode 100644
index 00000000000..fa5438ad2f6
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/js/CSS-supports-L4.txt
@@ -0,0 +1,24 @@
+Harness status: OK
+
+Found 18 tests
+
+14 Pass
+4 Fail
+Pass selector() function accepts a selector
+Pass selector() function doesn't accept a selector list
+Pass selector() function rejects unknown webkit pseudo-elements.
+Pass selector() function accepts known pseudo-elements
+Pass selector() with simple combinators
+Pass selector() with unknown combinators
+Fail selector() with forgiving :is, 1 arg
+Fail selector() with forgiving :is, multiple args
+Fail selector() with forgiving :where, 1 arg
+Fail selector() with forgiving :where, multiple args
+Pass selector() with forgiving :has, 1 arg
+Pass selector() with forgiving :has, multiple args
+Pass selector() with unforgiving :nth-child, 1 arg
+Pass selector() with unforgiving :nth-last-child, 1 arg
+Pass selector() with unforgiving :nth-child, multiple args
+Pass selector() with unforgiving :nth-last-child, multiple args
+Pass selector() with a non-identifier after :nth-child's An+B index
+Pass selector() with a non-identifier after :nth-last-child's An+B index
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/js/CSS-supports-selector-detecting-invalid-in-logical-combinations.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/js/CSS-supports-selector-detecting-invalid-in-logical-combinations.txt
new file mode 100644
index 00000000000..dd2af96053f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-conditional/js/CSS-supports-selector-detecting-invalid-in-logical-combinations.txt
@@ -0,0 +1,11 @@
+Harness status: OK
+
+Found 5 tests
+
+2 Pass
+3 Fail
+Pass Invalid selector can be detected with CSS.supports()
+Fail Invalid selector can be detected with CSS.supports() even if it is dropped by forgiving parsing
+Pass :is(), :where() or :has() always fails without argument
+Fail :has() always fails inside :has()
+Fail Some pseudo elements always fail inside :is(), :where(), :has()
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/js/CSS-supports-L4.html b/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/js/CSS-supports-L4.html
new file mode 100644
index 00000000000..e3cd15de24e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/js/CSS-supports-L4.html
@@ -0,0 +1,79 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS.supports() Level 4</title>
+<link rel="help" href="https://www.w3.org/TR/css-conditional-4/#the-css-namespace">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+ test(function() {
+ assert_equals(CSS.supports("selector(div)"), true);
+ }, "selector() function accepts a selector");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(div, div)"), false);
+ }, "selector() function doesn't accept a selector list");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(::-webkit-unknown-pseudo-element)"), false);
+ }, "selector() function rejects unknown webkit pseudo-elements.");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(::before)"), true);
+ }, "selector() function accepts known pseudo-elements");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(div + .c)"), true);
+ }, "selector() with simple combinators");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(div | .c)"), false);
+ }, "selector() with unknown combinators");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:is(:foo))"), false);
+ }, "selector() with forgiving :is, 1 arg");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:is(:foo, div))"), false);
+ }, "selector() with forgiving :is, multiple args");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:where(:foo))"), false);
+ }, "selector() with forgiving :where, 1 arg");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:where(:foo, div))"), false);
+ }, "selector() with forgiving :where, multiple args");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:has(:foo))"), false);
+ }, "selector() with forgiving :has, 1 arg");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:has(:foo, div))"), false);
+ }, "selector() with forgiving :has, multiple args");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:nth-child(2n + 3 of :foo))"), false);
+ }, "selector() with unforgiving :nth-child, 1 arg");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:nth-last-child(2n + 3 of :foo))"), false);
+ }, "selector() with unforgiving :nth-last-child, 1 arg");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:nth-child(2n + 3 of :foo, div))"), false);
+ }, "selector() with unforgiving :nth-child, multiple args");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:nth-last-child(2n + 3 of :foo, div))"), false);
+ }, "selector() with unforgiving :nth-last-child, multiple args");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:nth-child(2n 4))"), false);
+ }, "selector() with a non-identifier after :nth-child's An+B index");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:nth-last-child(2n 4))"), false);
+ }, "selector() with a non-identifier after :nth-last-child's An+B index");
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/js/CSS-supports-selector-detecting-invalid-in-logical-combinations.html b/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/js/CSS-supports-selector-detecting-invalid-in-logical-combinations.html
new file mode 100644
index 00000000000..bf7b84fbb52
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-conditional/js/CSS-supports-selector-detecting-invalid-in-logical-combinations.html
@@ -0,0 +1,58 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS.supports() detecting invalid in logical combinations</title>
+<link rel="help" href="https://www.w3.org/TR/css-conditional-4/#the-css-namespace">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+ test(function() {
+ assert_equals(CSS.supports("selector(:has(:foo))"), false);
+ assert_equals(CSS.supports("selector(:has(.a, :foo))"), false);
+ assert_equals(CSS.supports("selector(:has(:foo, .a))"), false);
+ assert_equals(CSS.supports("selector(:not(:foo))"), false);
+ assert_equals(CSS.supports("selector(:not(.a, :foo))"), false);
+ assert_equals(CSS.supports("selector(:not(:foo, .a))"), false);
+ }, "Invalid selector can be detected with CSS.supports()");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:is(:foo))"), false);
+ assert_equals(CSS.supports("selector(:is(.a, :foo))"), false);
+ assert_equals(CSS.supports("selector(:is(:foo, .a))"), false);
+ assert_equals(CSS.supports("selector(:is(:has(:foo, a), .b))"), false);
+ assert_equals(CSS.supports("selector(:where(:foo))"), false);
+ assert_equals(CSS.supports("selector(:where(.a, :foo))"), false);
+ assert_equals(CSS.supports("selector(:where(:foo, .a))"), false);
+ assert_equals(CSS.supports("selector(:where(:is(:foo, a), .b))"), false);
+ assert_equals(CSS.supports("selector(:has(:where(:foo, a), .b))"), false);
+ }, "Invalid selector can be detected with CSS.supports() even if it is dropped by forgiving parsing");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:is())"), false);
+ assert_equals(CSS.supports("selector(:where())"), false);
+ assert_equals(CSS.supports("selector(:has())"), false);
+ }, ":is(), :where() or :has() always fails without argument");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:has(:has(.a)))"), false);
+ assert_equals(CSS.supports("selector(:has(:has(.a), b))"), false);
+ assert_equals(CSS.supports("selector(.a, :has(:has(.b)))"), false);
+ assert_equals(CSS.supports("selector(:has(:is(:has(.a))))"), false);
+ assert_equals(CSS.supports("selector(:has(:is(:has(.a), .b)))"), false);
+ assert_equals(CSS.supports("selector(:has(:is(.a, :has(.b))))"), false);
+ }, ":has() always fails inside :has()");
+
+ test(function() {
+ assert_equals(CSS.supports("selector(:is(::after)"), false);
+ assert_equals(CSS.supports("selector(:is(::before)"), false);
+ assert_equals(CSS.supports("selector(:is(::first-letter)"), false);
+ assert_equals(CSS.supports("selector(:is(::first-line)"), false);
+ assert_equals(CSS.supports("selector(:where(::after)"), false);
+ assert_equals(CSS.supports("selector(:where(::before)"), false);
+ assert_equals(CSS.supports("selector(:where(::first-letter)"), false);
+ assert_equals(CSS.supports("selector(:where(::first-line)"), false);
+ assert_equals(CSS.supports("selector(:has(::after)"), false);
+ assert_equals(CSS.supports("selector(:has(::before)"), false);
+ assert_equals(CSS.supports("selector(:has(::first-letter)"), false);
+ assert_equals(CSS.supports("selector(:has(::first-line)"), false);
+ }, "Some pseudo elements always fail inside :is(), :where(), :has()");
+</script>