Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-view-transitions/parsing/pseudo-elements-invalid.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8">
<title>Test pseudo elements parsing of invalid selectors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
const functionPseudoElements = [
"::view-transition-group",
"::view-transition-image-pair",
"::view-transition-old",
"::view-transition-new",
];
function test_invalid_selector_combinations(pseudo) {
test_invalid_selector(`${pseudo}.a`);
test_invalid_selector(`${pseudo} div`);
test_invalid_selector(`${pseudo}:hover`);
test_invalid_selector(`${pseudo}:active`);
test_invalid_selector(`${pseudo}:first-child`);
test_invalid_selector(`${pseudo}:last-child`);
test_invalid_selector(`${pseudo}:empty`);
test_invalid_selector(`${pseudo}:visited`);
test_invalid_selector(`${pseudo}:enabled`);
test_invalid_selector(`:not(${pseudo})`);
test_invalid_selector(`:has(${pseudo})`);
}
test_invalid_selector_combinations("::view-transition");
test_invalid_selector("::view-transition:only-child");
test_invalid_selector("::view-transition(*)");
test_invalid_selector("::view-transition(valid)");
test_invalid_selector("::view-transition(root)");
for (const fn of functionPseudoElements) {
for (const validArgument of ["*", "valid", "root"]) {
test_invalid_selector_combinations(`${fn}(${validArgument})`);
}
// Test function without argument.
test_invalid_selector(fn);
test_invalid_selector_combinations(fn);
// Test function with empty argument.
test_invalid_selector(`${fn}()`);
test_invalid_selector_combinations(`${fn}()`);
// Test function with keywords excluded from <custom-ident>.
test_invalid_selector(`${fn}(default)`);
test_invalid_selector_combinations(`${fn}(default)`);
test_invalid_selector(`${fn}(unset)`);
test_invalid_selector_combinations(`${fn}(unset)`);
test_invalid_selector(`${fn}(initial)`);
test_invalid_selector_combinations(`${fn}(initial)`);
test_invalid_selector(`${fn}(inherit)`);
test_invalid_selector_combinations(`${fn}(inherit)`);
test_invalid_selector(`${fn}(revert)`);
test_invalid_selector_combinations(`${fn}(revert)`);
test_invalid_selector(`${fn}(revert-layer)`);
test_invalid_selector_combinations(`${fn}(revert-layer)`);
// Test function with multiple arguments.
test_invalid_selector(`${fn}(foo, bar)`);
test_invalid_selector_combinations(`${fn}(foo, bar)`);
test_invalid_selector(`${fn}(foo bar)`);
test_invalid_selector_combinations(`${fn}(foo bar)`);
// Test function with selector arguments.
test_invalid_selector(`${fn}(#bar)`);
test_invalid_selector_combinations(`${fn}(#bar)`);
}
</script>