summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-syntax/non-ascii-codepoints.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-syntax/non-ascii-codepoints.html
parentInitial commit. (diff)
downloadfirefox-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/non-ascii-codepoints.html')
-rw-r--r--testing/web-platform/tests/css/css-syntax/non-ascii-codepoints.html81
1 files changed, 81 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-syntax/non-ascii-codepoints.html b/testing/web-platform/tests/css/css-syntax/non-ascii-codepoints.html
new file mode 100644
index 0000000000..c416955d4e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-syntax/non-ascii-codepoints.html
@@ -0,0 +1,81 @@
+<!doctype html>
+<title>Non-ASCII codepoints</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<meta name="author" title="Tab Atkins-Bittner">
+<link rel=help href="https://drafts.csswg.org/css-syntax/#non-ascii-ident-code-point">
+
+<script>
+function validIdentChar(cp) {
+ // Reset to a known-good ident
+ document.head.style.animationName = "foo";
+ // Then change to a name containing the char
+ document.head.style.animationName = "f"+String.fromCodePoint(cp)+"oo";
+ // And see if it actually changed.
+ return document.head.style.animationName != "foo";
+}
+
+function testValid(cp) {
+ test(()=>{
+ assert_true(validIdentChar(cp));
+ }, `Codepoint U+${cp.toString(16)} is a valid 'non-ASCII ident codepoint'.`)
+}
+
+function testInvalid(cp) {
+ // Just skip if the codepoint is outside the possible range.
+ if(cp > 0x1ffff) return;
+ test(()=>{
+ assert_false(validIdentChar(cp));
+ }, `Codepoint U+${cp.toString(16)} is not a 'non-ASCII ident codepoint'.`)
+}
+
+function testValidRanges(ranges) {
+ // Takes an array of codepoints or codepoints ranges,
+ // and tests whether the start, end, and middle of
+ // each range is valid, and confirms that the
+ // start/end of the regions between them are invalid.
+
+ for(const range of ranges) {
+ if(typeof range == "number") {
+ testValid(range);
+ continue;
+ }
+ testValid(range[0]);
+ if(range[1] - range[0] > 1) {
+ testValid(Math.floor((range[0]+range[1])/2));
+ }
+ testValid(range[1]);
+ }
+ testInvalid(0x80);
+ var lastTested = 0x80;
+ for(const range of ranges) {
+ if(typeof range == "number") {
+ if(range-1 != lastTested) testInvalid(range-1);
+ testInvalid(range+1);
+ lastTested = range+1;
+ continue;
+ }
+ if(range[0]-1 != lastTested) testInvalid(range[0]-1);
+ testInvalid(range[1]+1);
+ lastTested = range[1]+1;
+ }
+
+}
+
+testValidRanges([
+ 0xb7,
+ [0xc0, 0xd6],
+ [0xd8, 0xf6],
+ [0xf8, 0x37d],
+ [0x37f, 0x1fff],
+ [0x200c, 0x200d],
+ [0x203f, 0x2040]
+ [0x2070, 0x218f],
+ [0x2c00, 0x2fef],
+ [0x3001, 0xd7ff],
+ [0xf900, 0xfdcf],
+ [0xfdf0, 0xfffd],
+ [0x10000, 0x1ffff],
+]);
+</script> \ No newline at end of file