summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js')
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js b/js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js
new file mode 100644
index 0000000000..76dd9cf5ec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.with
+description: >
+ Array.prototype.with limits the length to 2 ** 32 - 1
+info: |
+ Array.prototype.with ( index, value )
+
+ ...
+ 2. Let len be ? LengthOfArrayLike(O).
+ ...
+ 7. Let A be ? ArrayCreate(𝔽(len)).
+ ...
+
+ ArrayCreate ( length [, proto ] )
+
+ 1. If length > 2 ** 32 - 1, throw a RangeError exception.
+features: [change-array-by-copy, exponentiation]
+---*/
+
+// Object with large "length" property
+var arrayLike = {
+ get "0"() {
+ throw new Test262Error("Get 0");
+ },
+ get "4294967295" () { // 2 ** 32 - 1
+ throw new Test262Error("Get 4294967295");
+ },
+ get "4294967296" () { // 2 ** 32
+ throw new Test262Error("Get 4294967296");
+ },
+ length: 2 ** 32
+};
+
+assert.throws(RangeError, function() {
+ Array.prototype.with.call(arrayLike, 0, 0);
+});
+
+reportCompare(0, 0);