diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-syntax/anb-parsing.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-syntax/anb-parsing.html')
-rw-r--r-- | testing/web-platform/tests/css/css-syntax/anb-parsing.html | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-syntax/anb-parsing.html b/testing/web-platform/tests/css/css-syntax/anb-parsing.html new file mode 100644 index 0000000000..7fcc06e2c7 --- /dev/null +++ b/testing/web-platform/tests/css/css-syntax/anb-parsing.html @@ -0,0 +1,125 @@ +<!doctype html> +<title>An+B Parsing</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + +foo { color: blue; } + +</style> + +<meta name="author" title="Tab Atkins-Bittner"> +<link rel=help href="https://drafts.csswg.org/css-syntax/#the-anb-type"> + +<script> + +function roundtripANB(str) { + const rule = document.styleSheets[0].cssRules[0]; + rule.selectorText = "foo"; + rule.selectorText = `:nth-child(${str})`; + // Check for parse error. + if(rule.selectorText == "foo") return "parse error"; + return rule.selectorText.slice(11, -1); +} +function testANB(input, expected) { + test(()=>{ + assert_equals(roundtripANB(input), expected); + }, `"${input}" becomes "${expected}"`); +} + +/* Just going down all the syntax clauses one-by-one */ +// odd | even | +testANB("odd", "2n+1"); +testANB("even", "2n"); +// <integer> | +testANB("1", "1"); +testANB("+1", "1"); +testANB("-1", "-1"); +// +// <n-dimension> | +testANB("5n", "5n"); +testANB("5N", "5n"); +// '+'?† n | +testANB("+n", "n"); +testANB("n", "n"); +testANB("N", "n"); +testANB("+ n", "parse error"); +// -n | +testANB("-n", "-n"); +testANB("-N", "-n"); +// +// <ndashdigit-dimension> | +testANB("5n-5", "5n-5"); +// '+'?† <ndashdigit-ident> | +testANB("+n-5", "n-5"); +testANB("n-5", "n-5"); +testANB("+ n-5", "parse error"); +// <dashndashdigit-ident> | +testANB("-n-5", "-n-5"); +// +// <n-dimension> <signed-integer> | +testANB("5n +5", "5n+5"); +testANB("5n -5", "5n-5"); +// '+'?† n <signed-integer> | +testANB("+n +5", "n+5"); +testANB("n +5", "n+5"); +testANB("+n -5", "n-5"); +testANB("+ n +5", "parse error"); +testANB("n 5", "parse error"); +// -n <signed-integer> | +testANB("-n +5", "-n+5"); +testANB("-n -5", "-n-5"); +testANB("-n 5", "parse error"); +// +// <ndash-dimension> <signless-integer> | +testANB("5n- 5", "5n-5"); +testANB("5n- -5", "parse error"); +testANB("5n- +5", "parse error"); +testANB("-5n- 5", "-5n-5"); +// '+'?† n- <signless-integer> | +testANB("+n- 5", "n-5"); +testANB("n- 5", "n-5"); +testANB("+ n- 5", "parse error"); +testANB("n- +5", "parse error"); +testANB("n- -5", "parse error"); +// -n- <signless-integer> | +testANB("-n- 5", "-n-5"); +testANB("-n- +5", "parse error"); +testANB("-n- -5", "parse error"); +// +// <n-dimension> ['+' | '-'] <signless-integer> +testANB("5n + 5", "5n+5"); +testANB("5n - 5", "5n-5"); +testANB("5n + +5", "parse error"); +testANB("5n + -5", "parse error"); +testANB("5n - +5", "parse error"); +testANB("5n - -5", "parse error"); +// '+'?† n ['+' | '-'] <signless-integer> | +testANB("+n + 5", "n+5"); +testANB("n + 5", "n+5"); +testANB("+ n + 5", "parse error"); +testANB("+n - 5", "n-5"); +testANB("+n + +5", "parse error"); +testANB("+n + -5", "parse error"); +testANB("+n - +5", "parse error"); +testANB("+n - -5", "parse error"); +// -n ['+' | '-'] <signless-integer> +testANB("-n + 5", "-n+5"); +testANB("-n - 5", "-n-5"); +testANB("-n + +5", "parse error"); +testANB("-n + -5", "parse error"); +testANB("-n - +5", "parse error"); +testANB("-n - -5", "parse error"); + +/* Swapped ordering is invalid */ +testANB("1 - n", "parse error"); +testANB("0 - n", "parse error"); +testANB("-1 + n", "parse error"); + +/* Odd space usage */ +testANB("2 n + 2", "parse error"); +testANB("- 2n", "parse error"); +testANB("+ 2n", "parse error"); +testANB("+2 n", "parse error"); + +</script> |