diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-syntax/custom-property-rule-ambiguity.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-syntax/custom-property-rule-ambiguity.html')
-rw-r--r-- | testing/web-platform/tests/css/css-syntax/custom-property-rule-ambiguity.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-syntax/custom-property-rule-ambiguity.html b/testing/web-platform/tests/css/css-syntax/custom-property-rule-ambiguity.html new file mode 100644 index 0000000000..50728bc94c --- /dev/null +++ b/testing/web-platform/tests/css/css-syntax/custom-property-rule-ambiguity.html @@ -0,0 +1,84 @@ +<!DOCTYPE html> +<title>CSS Syntax: Rules that look like custom properties</title> +<link rel="help" href="https://drafts.csswg.org/css-syntax/#consume-qualified-rule"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<style id=stylesheet1> + .a { } + --x:hover { } /* Ambiguous "rule" */ + .b { } +</style> +<script> + test(() => { + let rules = stylesheet1.sheet.rules; + assert_equals(rules.length, 2); + assert_equals(rules[0].selectorText, '.a'); + assert_equals(rules[1].selectorText, '.b'); + }, 'Rule that looks like a custom property declaration is ignored'); +</script> + +<!-- https://github.com/w3c/csswg-drafts/issues/9336 --> +<style id=stylesheet2> + .a { } + --x:hover { ] } /* Ambiguous "rule" */ + .b { } +</style> +<script> + test(() => { + let rules = stylesheet2.sheet.rules; + assert_equals(rules.length, 2); + assert_equals(rules[0].selectorText, '.a'); + assert_equals(rules[1].selectorText, '.b'); + }, 'Rule that looks like an invalid custom property declaration is ignored'); +</script> + +<style id=stylesheet3> + div { + .a { } + --x:hover { } + .b { } + } +</style> +<script> + test(() => { + let rules = stylesheet3.sheet.rules; + assert_equals(rules.length, 1); + assert_equals(rules[0].selectorText, 'div'); + let div = rules[0]; + let x = div.style.getPropertyValue('--x'); + assert_equals(x, 'hover { }\n .b { }'); + let childRules = div.cssRules; + assert_equals(childRules.length, 1); + assert_equals(childRules[0].selectorText, '.a'); + }, 'Nested rule that looks like a custom property declaration'); +</script> + +<!-- https://github.com/w3c/csswg-drafts/issues/9336 --> + +<style id=stylesheet4> + div { + .a { } + --x:hover { ] } + .b { } + } +</style> +<script> + test(() => { + let rules = stylesheet4.sheet.rules; + assert_equals(rules.length, 1); + assert_equals(rules[0].selectorText, 'div'); + let div = rules[0]; + // There is no valid --x declaration, because mismatched ] is not allowed + // in custom properties. + let x = div.style.getPropertyValue('--x'); + assert_equals(x, ''); + // We should also not have restarted parsing as a nested style rule, + // and instead we should have "consumed the remnants of a bad declaration", + // which skips to the next semicolon (or end-of-block). + // So in other words, there should be no nested '.b.' child rule here. + let childRules = div.cssRules; + assert_equals(childRules.length, 1); + assert_equals(childRules[0].selectorText, '.a'); + }, 'Nested rule that looks like an invalid custom property declaration'); +</script> |