summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Locale/canonicalize-locale-list-take-locale.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/Locale/canonicalize-locale-list-take-locale.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/Locale/canonicalize-locale-list-take-locale.js')
-rw-r--r--js/src/tests/test262/intl402/Locale/canonicalize-locale-list-take-locale.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Locale/canonicalize-locale-list-take-locale.js b/js/src/tests/test262/intl402/Locale/canonicalize-locale-list-take-locale.js
new file mode 100644
index 0000000000..1f20ba61fb
--- /dev/null
+++ b/js/src/tests/test262/intl402/Locale/canonicalize-locale-list-take-locale.js
@@ -0,0 +1,55 @@
+// Copyright 2019 Google Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-intl.locale
+description: >
+ Verifies CanonicalizeLocaleList will take Intl.Locale as locales.
+info: |
+ CanonicalizeLocaleList ( locales )
+ 3. If Type(locales) is String or locales has an [[InitializedLocale]] internal slot, then
+ a. Let O be CreateArrayFromList(« locales »).
+
+ c. iii. If Type(kValue) is Object and kValue has an [[InitializedLocale]] internal slot, then
+ 1. Let tag be kValue.[[Locale]].
+ iv. Else,
+ 1. Let tag be ? ToString(kValue).
+features: [Intl.Locale]
+---*/
+
+const tag = "ar";
+const tag2 = "fa";
+const tag3 = "zh";
+const loc = new Intl.Locale(tag);
+
+// Monkey-patching Intl.Locale
+class PatchedLocale extends Intl.Locale {
+ constructor(tag, options) {
+ super(tag, options);
+ }
+ toString() {
+ // this should NOT get called.
+ assert(false, "toString should not be called")
+ }
+}
+const ploc = new PatchedLocale(tag2);
+
+// Test Intl.Locale as the only argument
+let res = Intl.getCanonicalLocales(loc);
+assert.sameValue(res.length, 1);
+assert.sameValue(res[0], tag);
+
+// Test Monkey-patched Intl.Locale as the only argument
+res = Intl.getCanonicalLocales(ploc);
+assert.sameValue(res.length, 1);
+assert.sameValue(res[0], tag2);
+
+// Test Intl.Locale and the Monkey-patched one are in
+// array.
+res = Intl.getCanonicalLocales([loc, tag3, ploc]);
+assert.sameValue(res.length, 3);
+assert.sameValue(res[0], tag);
+assert.sameValue(res[1], tag3);
+assert.sameValue(res[2], tag2);
+
+reportCompare(0, 0);