summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Collator/ignore-invalid-unicode-ext-values.js
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 /js/src/tests/test262/intl402/Collator/ignore-invalid-unicode-ext-values.js
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 'js/src/tests/test262/intl402/Collator/ignore-invalid-unicode-ext-values.js')
-rw-r--r--js/src/tests/test262/intl402/Collator/ignore-invalid-unicode-ext-values.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Collator/ignore-invalid-unicode-ext-values.js b/js/src/tests/test262/intl402/Collator/ignore-invalid-unicode-ext-values.js
new file mode 100644
index 0000000000..0e36be1160
--- /dev/null
+++ b/js/src/tests/test262/intl402/Collator/ignore-invalid-unicode-ext-values.js
@@ -0,0 +1,48 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+es5id: 10.2.3_b
+description: >
+ Tests that Intl.Collator does not accept Unicode locale extension
+ keys and values that are not allowed.
+author: Norbert Lindenberg
+includes: [compareArray.js]
+---*/
+
+var testArray = [
+ "hello", "你好", "こんにちは",
+ "pêche", "peché", "1", "9", "10",
+ "ụ\u031B", "u\u031B\u0323", "ư\u0323", "u\u0323\u031B",
+ "Å", "Å", "A\u030A"
+];
+
+var defaultCollator = new Intl.Collator();
+var defaultOptions = defaultCollator.resolvedOptions();
+var defaultOptionsJSON = JSON.stringify(defaultOptions);
+var defaultLocale = defaultOptions.locale;
+var defaultSortedArray = testArray.slice(0).sort(defaultCollator.compare);
+
+var keyValues = {
+ "co": ["standard", "search", "invalid"],
+ "ka": ["noignore", "shifted", "invalid"],
+ "kb": ["true", "false", "invalid"],
+ "kc": ["true", "false", "invalid"],
+ "kh": ["true", "false", "invalid"],
+ "kk": ["true", "false", "invalid"],
+ "kr": ["latn-hira-hani", "hani-hira-latn", "invalid"],
+ "ks": ["level1", "level2", "level3", "level4", "identic", "invalid"],
+ "vt": ["1234-5678-9abc-edf0", "invalid"]
+};
+
+Object.getOwnPropertyNames(keyValues).forEach(function (key) {
+ keyValues[key].forEach(function (value) {
+ var collator = new Intl.Collator([defaultLocale + "-u-" + key + "-" + value]);
+ var options = collator.resolvedOptions();
+ assert.sameValue(options.locale, defaultLocale, "Locale " + options.locale + " is affected by key " + key + "; value " + value + ".");
+ assert.sameValue(JSON.stringify(options), defaultOptionsJSON, "Resolved options " + JSON.stringify(options) + " are affected by key " + key + "; value " + value + ".");
+ assert.compareArray(testArray.sort(collator.compare), defaultSortedArray);
+ });
+});
+
+reportCompare(0, 0);