diff options
Diffstat (limited to 'testing/web-platform/tests/css/selectors/parsing')
13 files changed, 248 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-attribute.html b/testing/web-platform/tests/css/selectors/parsing/parse-attribute.html new file mode 100644 index 0000000000..a8fcfb24f5 --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-attribute.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: Attribute selectors</title> +<link rel="help" href="https://drafts.csswg.org/selectors-3/#attribute-selectors"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + // Attribute presence and value selectors + test_valid_selector('[att]'); + test_valid_selector('[att=val]', '[att="val"]'); + test_valid_selector('[att~=val]', '[att~="val"]'); + test_valid_selector('[att|=val]', '[att|="val"]'); + test_valid_selector('h1[title]'); + test_valid_selector("span[class='example']", 'span[class="example"]'); + test_valid_selector('a[hreflang=fr]', 'a[hreflang="fr"]'); + test_valid_selector("a[hreflang|='en']", 'a[hreflang|="en"]'); + + // Substring matching attribute selectors + test_valid_selector('[att^=val]', '[att^="val"]'); + test_valid_selector('[att$=val]', '[att$="val"]'); + test_valid_selector('[att*=val]', '[att*="val"]'); + test_valid_selector('object[type^="image/"]'); + test_valid_selector('a[href$=".html"]'); + test_valid_selector('p[title*="hello"]'); + + // From Attribute selectors and namespaces examples in spec: + test_valid_selector('[*|att]'); + test_valid_selector('[|att]', '[att]'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-child.html b/testing/web-platform/tests/css/selectors/parsing/parse-child.html new file mode 100644 index 0000000000..510c45db86 --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-child.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: Child combinators</title> +<link rel="help" href="https://drafts.csswg.org/selectors-3/#child-combinators"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector('body > p'); + test_valid_selector('div ol>li p', 'div ol > li p'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-class.html b/testing/web-platform/tests/css/selectors/parsing/parse-class.html new file mode 100644 index 0000000000..00abcf838d --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-class.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: Class selectors</title> +<link rel="help" href="https://drafts.csswg.org/selectors-3/#class-html"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector('*.pastoral', + ['*.pastoral', '.pastoral']); + test_valid_selector('.pastoral', + ['*.pastoral', '.pastoral']); + test_valid_selector('h1.pastoral'); + test_valid_selector('p.pastoral.marine'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-descendant.html b/testing/web-platform/tests/css/selectors/parsing/parse-descendant.html new file mode 100644 index 0000000000..5ff3a7bbfd --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-descendant.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: Descendant combinator</title> +<link rel="help" href="https://drafts.csswg.org/selectors-3/#descendant-combinators"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector('h1 em'); + test_valid_selector('div * p'); + test_valid_selector('div p *[href]', + ['div p *[href]', 'div p [href]']); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-focus-visible.html b/testing/web-platform/tests/css/selectors/parsing/parse-focus-visible.html new file mode 100644 index 0000000000..52ac963add --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-focus-visible.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: :focus-visible pseudo-class</title> +<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-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(':focus-visible'); + test_valid_selector('a:focus-visible'); + test_valid_selector(':focus:not(:focus-visible)'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-has-disallow-nesting-has-inside-has.html b/testing/web-platform/tests/css/selectors/parsing/parse-has-disallow-nesting-has-inside-has.html new file mode 100644 index 0000000000..9cf989fcbe --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-has-disallow-nesting-has-inside-has.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: The relational pseudo-class (disallow nesting :has() inside :has())</title> +<link rel="author" title="Byungwoo Lee" href="mailto:blee@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/selectors-4/#has-pseudo"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_invalid_selector('.a:has(.b:has(.c))'); + test_valid_selector('.a:has(:is(.b:has(.c)))', '.a:has(:is())'); + test_valid_selector('.a:has(:is(.b:has(.c), .d))', '.a:has(:is(.d))'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-has.html b/testing/web-platform/tests/css/selectors/parsing/parse-has.html new file mode 100644 index 0000000000..5d071010b4 --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-has.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: The relational pseudo-class</title> +<link rel="author" title="Byungwoo Lee" href="mailto:blee@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/selectors-4/#has-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(':has(a)'); + test_valid_selector(':has(#a)'); + test_valid_selector(':has(.a)'); + test_valid_selector(':has([a])'); + test_valid_selector(':has([a="b"])'); + test_valid_selector(':has([a|="b"])'); + test_valid_selector(':has(:hover)'); + test_valid_selector('*:has(.a)', ['*:has(.a)', ':has(.a)']); + test_valid_selector('.a:has(.b)'); + test_valid_selector('.a:has(> .b)'); + test_valid_selector('.a:has(~ .b)'); + test_valid_selector('.a:has(+ .b)'); + test_valid_selector('.a:has(.b) .c'); + test_valid_selector('.a .b:has(.c)'); + test_valid_selector('.a .b:has(.c .d)'); + test_valid_selector('.a .b:has(.c .d) .e'); + test_valid_selector('.a:has(.b:is(.c .d))'); + test_valid_selector('.a:is(.b:has(.c) .d)'); + test_valid_selector('.a:not(:has(.b))'); + test_valid_selector('.a:has(:not(.b))'); + test_valid_selector('.a:has(.b):has(.c)'); + test_valid_selector('*|*:has(*)', ':has(*)'); + test_valid_selector(':has(*|*)', ':has(*)'); + test_invalid_selector(':has'); + test_invalid_selector('.a:has'); + test_invalid_selector('.a:has b'); + /* :has() is unforgiving, but :is() can still forgive */ + test_invalid_selector(':has()'); + test_invalid_selector(':has(123)'); + test_invalid_selector(':has(.a, 123)'); + test_valid_selector(':has(:is(.a, 123))', ':has(:is(.a))'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-id.html b/testing/web-platform/tests/css/selectors/parsing/parse-id.html new file mode 100644 index 0000000000..2441c4217e --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-id.html @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: ID selectors</title> +<link rel="help" href="https://drafts.csswg.org/selectors-3/#id-selectors"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector('h1#chapter1'); + test_valid_selector('#chapter1'); + test_valid_selector('*#z98y', + ['*#z98y', '#z98y']); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-is.html b/testing/web-platform/tests/css/selectors/parsing/parse-is.html new file mode 100644 index 0000000000..68236445c5 --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-is.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: The Matches-Any Pseudo-class: ':is()'</title> +<link rel="help" href="https://drafts.csswg.org/selectors/#matches"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector(':is(ul,ol,.list) > [hidden]', + ':is(ul, ol, .list) > [hidden]'); + test_valid_selector(':is(:hover,:focus)', + ':is(:hover, :focus)'); + test_valid_selector('a:is(:not(:hover))'); + + test_valid_selector(':is(#a)'); + test_valid_selector('.a.b ~ :is(.c.d ~ .e.f)'); + test_valid_selector('.a.b ~ .c.d:is(span.e + .f, .g.h > .i.j .k)'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-not.html b/testing/web-platform/tests/css/selectors/parsing/parse-not.html new file mode 100644 index 0000000000..f455059251 --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-not.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: The negation pseudo-class</title> +<link rel="help" href="https://drafts.csswg.org/selectors-3/#negation"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector('button:not([disabled])'); + test_valid_selector('*:not(foo)', + ['*:not(foo)', ':not(foo)']); + test_valid_selector(':not(:link):not(:visited)'); + test_valid_selector('*|*:not(*)', ':not(*)'); + test_valid_selector(':not(:hover)'); + test_valid_selector(':not(*|*)', ':not(*)'); + test_valid_selector('foo:not(bar)'); + test_valid_selector(':not(:not(foo))'); + test_valid_selector(':not(.a .b)'); + test_valid_selector(':not(.a + .b)'); + test_valid_selector(':not(.a .b ~ c)'); + test_valid_selector(':not(span.a, div.b)'); + test_valid_selector(':not(.a .b ~ c, .d .e)'); + test_valid_selector(':not(:host)'); + test_valid_selector(':not(:host(.a))'); + test_valid_selector(':host(:not(.a))'); + test_valid_selector(':not(:host(:not(.a)))'); + test_valid_selector(':not([disabled][selected])', ':not([disabled][selected])'); + test_valid_selector(':not([disabled],[selected])', ':not([disabled], [selected])'); + + test_invalid_selector(':not()'); + test_invalid_selector(':not(:not())'); + test_invalid_selector(':not(::before)'); + test_invalid_selector(':not(:unknownpseudo)'); + test_invalid_selector(':not(.a, :unknownpseudo)'); + test_invalid_selector(':not(:unknownpseudo, .a)'); + test_invalid_selector(':host(:not(.a .b))'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-sibling.html b/testing/web-platform/tests/css/selectors/parsing/parse-sibling.html new file mode 100644 index 0000000000..4f7a7a3fbc --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-sibling.html @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: Sibling combinators</title> +<link rel="help" href="https://drafts.csswg.org/selectors-3/#sibling-combinators"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector('math + p'); + test_valid_selector('h1.opener + h2'); + test_valid_selector('h1 ~ pre'); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-universal.html b/testing/web-platform/tests/css/selectors/parsing/parse-universal.html new file mode 100644 index 0000000000..e944a93f12 --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-universal.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: Universal selector</title> +<link rel="help" href="https://drafts.csswg.org/selectors-3/#universal-selector"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector('*'); + test_valid_selector('div :first-child', + ['div *:first-child', 'div :first-child']); + test_valid_selector('div *:first-child', + ['div *:first-child', 'div :first-child']); +</script> diff --git a/testing/web-platform/tests/css/selectors/parsing/parse-where.html b/testing/web-platform/tests/css/selectors/parsing/parse-where.html new file mode 100644 index 0000000000..3a90969570 --- /dev/null +++ b/testing/web-platform/tests/css/selectors/parsing/parse-where.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Selectors: The Specificity-adjustment Pseudo-class: ':where()'</title> +<link rel="help" href="https://drafts.csswg.org/selectors/#zero-matches"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +<script> + test_valid_selector(':where(ul,ol,.list) > [hidden]', + ':where(ul, ol, .list) > [hidden]'); + test_valid_selector(':where(:hover,:focus)', + ':where(:hover, :focus)'); + test_valid_selector('a:where(:not(:hover))'); + + test_valid_selector(':where(#a)'); + test_valid_selector('.a.b ~ :where(.c.d ~ .e.f)'); + test_valid_selector('.a.b ~ .c.d:where(span.e + .f, .g.h > .i.j .k)'); +</script> |