diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/intl402/Intl/getCanonicalLocales/overriden-arg-length.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/Intl/getCanonicalLocales/overriden-arg-length.js')
-rw-r--r-- | js/src/tests/test262/intl402/Intl/getCanonicalLocales/overriden-arg-length.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Intl/getCanonicalLocales/overriden-arg-length.js b/js/src/tests/test262/intl402/Intl/getCanonicalLocales/overriden-arg-length.js new file mode 100644 index 0000000000..3d781c0301 --- /dev/null +++ b/js/src/tests/test262/intl402/Intl/getCanonicalLocales/overriden-arg-length.js @@ -0,0 +1,103 @@ +// Copyright 2016 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-intl.getcanonicallocales +description: Test Intl.getCanonicalLocales for step 5. +info: | + 9.2.1 CanonicalizeLocaleList (locales) + 5. Let len be ? ToLength(? Get(O, "length")). +includes: [compareArray.js] +features: [Symbol] +---*/ + +var locales = { + '0': 'en-US', +}; + +Object.defineProperty(locales, "length", { + get: function() { throw new Test262Error() } +}); + +assert.throws(Test262Error, function() { + Intl.getCanonicalLocales(locales); +}, "should throw if locales.length throws"); + +var locales = { + '0': 'en-US', + '1': 'pt-BR', +}; + +Object.defineProperty(locales, "length", { + get: function() { return "1" } +}); + +assert.compareArray( + Intl.getCanonicalLocales(locales), + ['en-US'], + "should return one element if locales.length is '1'" +); + +var locales = { + '0': 'en-US', + '1': 'pt-BR', +}; + +Object.defineProperty(locales, "length", { + get: function() { return 1.3 } +}); + +assert.compareArray( + Intl.getCanonicalLocales(locales), + ['en-US'], + "should return one element if locales.length is 1.3" +); + +var locales = { + '0': 'en-US', + '1': 'pt-BR', +}; + +Object.defineProperty(locales, "length", { + get: function() { return Symbol("1.8") } +}); + +assert.throws(TypeError, function() { + Intl.getCanonicalLocales(locales); +}, "should throw if locales.length is a Symbol"); + +var locales = { + '0': 'en-US', + '1': 'pt-BR', +}; + +Object.defineProperty(locales, "length", { + get: function() { return -Infinity } +}); + +assert.compareArray( + Intl.getCanonicalLocales(locales), + [], + "should return empty array if locales.length is -Infinity" +); + +var locales = { + length: -Math.pow(2, 32) + 1 +}; + +Object.defineProperty(locales, "0", { + get: function() { throw new Error("must not be gotten!"); } +}) + +assert.compareArray( + Intl.getCanonicalLocales(locales), + [], + "should return empty array if locales.length is a negative value" +); + +var count = 0; +var locs = { get length() { if (count++ > 0) throw 42; return 0; } }; +var locales = Intl.getCanonicalLocales(locs); // shouldn't throw 42 +assert.sameValue(locales.length, 0); + +reportCompare(0, 0); |