summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/length
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/built-ins/Array/length
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/built-ins/Array/length')
-rw-r--r--js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-1.js17
-rw-r--r--js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-2.js17
-rw-r--r--js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-3.js15
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T1.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js18
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js20
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js14
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js22
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js46
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js46
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js46
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js25
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js32
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js13
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js47
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js59
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js35
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js114
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js24
-rw-r--r--js/src/tests/test262/built-ins/Array/length/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js48
-rw-r--r--js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js63
-rw-r--r--js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js26
-rw-r--r--js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js64
-rw-r--r--js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-order.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-realm.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/length/shell.js0
32 files changed, 1012 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-1.js b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-1.js
new file mode 100644
index 0000000000..4cb377f025
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-1.js
@@ -0,0 +1,17 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-properties-of-array-instances-length
+es5id: 15.4.5.1-3.d-1
+description: >
+ Throw RangeError if attempt to set array length property to
+ 4294967296 (2**32)
+---*/
+
+
+assert.throws(RangeError, function() {
+ [].length = 4294967296;
+}, '[].length = 4294967296 throws a RangeError exception');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-2.js b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-2.js
new file mode 100644
index 0000000000..f899eb15b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-2.js
@@ -0,0 +1,17 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-properties-of-array-instances-length
+es5id: 15.4.5.1-3.d-2
+description: >
+ Throw RangeError if attempt to set array length property to
+ 4294967297 (1+2**32)
+---*/
+
+
+assert.throws(RangeError, function() {
+ [].length = 4294967297;
+}, '[].length = 4294967297 throws a RangeError exception');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-3.js b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-3.js
new file mode 100644
index 0000000000..478e4560a9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/15.4.5.1-3.d-3.js
@@ -0,0 +1,15 @@
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-properties-of-array-instances-length
+es5id: 15.4.5.1-3.d-3
+description: Set array length property to max value 4294967295 (2**32-1,)
+---*/
+
+var a = [];
+a.length = 4294967295;
+
+assert.sameValue(a.length, 4294967295, 'The value of a.length is expected to be 4294967295');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T1.js
new file mode 100644
index 0000000000..c8c9391b08
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T1.js
@@ -0,0 +1,20 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ The [[Prototype]] property of the newly constructed object
+ is set to the original Array prototype object, the one that
+ is the initial value of Array.prototype
+es5id: 15.4.2.2_A1.1_T1
+description: >
+ Create new property of Array.prototype. When new Array object has
+ this property
+---*/
+
+Array.prototype.myproperty = 1;
+var x = new Array(0);
+assert.sameValue(x.myproperty, 1, 'The value of x.myproperty is expected to be 1');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js
new file mode 100644
index 0000000000..b0f1321367
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js
@@ -0,0 +1,18 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ The [[Prototype]] property of the newly constructed object
+ is set to the original Array prototype object, the one that
+ is the initial value of Array.prototype
+es5id: 15.4.2.2_A1.1_T2
+description: Array.prototype.toString = Object.prototype.toString
+---*/
+
+Array.prototype.toString = Object.prototype.toString;
+var x = new Array(0);
+assert.sameValue(x.toString(), "[object Array]", 'x.toString() must return "[object Array]"');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js
new file mode 100644
index 0000000000..4fcb4cfc76
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js
@@ -0,0 +1,20 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ The [[Prototype]] property of the newly constructed object
+ is set to the original Array prototype object, the one that
+ is the initial value of Array.prototype
+es5id: 15.4.2.2_A1.1_T3
+description: Checking use isPrototypeOf
+---*/
+
+assert.sameValue(
+ Array.prototype.isPrototypeOf(new Array(0)),
+ true,
+ 'Array.prototype.isPrototypeOf(new Array(0)) must return true'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js
new file mode 100644
index 0000000000..1e6c52e8cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js
@@ -0,0 +1,14 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: The [[Class]] property of the newly constructed object is set to "Array"
+es5id: 15.4.2.2_A1.2_T1
+description: Checking use Object.prototype.toString
+---*/
+
+var x = new Array(0);
+assert.sameValue(Object.prototype.toString.call(x), "[object Array]", 'Object.prototype.toString.call(new Array(0)) must return "[object Array]"');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js
new file mode 100644
index 0000000000..da22b03edc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js
@@ -0,0 +1,22 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is a Number and ToUint32(len) is equal to len,
+ then the length property of the newly constructed object is set to ToUint32(len)
+es5id: 15.4.2.2_A2.1_T1
+description: Array constructor is given one argument
+---*/
+
+var x = new Array(0);
+assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0');
+
+var x = new Array(1);
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+
+var x = new Array(4294967295);
+assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js
new file mode 100644
index 0000000000..87243a739e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js
@@ -0,0 +1,46 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is a Number and ToUint32(len) is not equal to len,
+ a RangeError exception is thrown
+es5id: 15.4.2.2_A2.2_T1
+description: Use try statement. len = -1, 4294967296, 4294967297
+---*/
+
+try {
+ new Array(-1);
+ throw new Test262Error('#1.1: new Array(-1) throw RangeError. Actual: ' + (new Array(-1)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ new Array(4294967296);
+ throw new Test262Error('#2.1: new Array(4294967296) throw RangeError. Actual: ' + (new Array(4294967296)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ new Array(4294967297);
+ throw new Test262Error('#3.1: new Array(4294967297) throw RangeError. Actual: ' + (new Array(4294967297)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js
new file mode 100644
index 0000000000..9785dccba0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js
@@ -0,0 +1,46 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is a Number and ToUint32(len) is not equal to len,
+ a RangeError exception is thrown
+es5id: 15.4.2.2_A2.2_T2
+description: Use try statement. len = NaN, +/-Infinity
+---*/
+
+try {
+ new Array(NaN);
+ throw new Test262Error('#1.1: new Array(NaN) throw RangeError. Actual: ' + (new Array(NaN)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ new Array(Number.POSITIVE_INFINITY);
+ throw new Test262Error('#2.1: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.POSITIVE_INFINITY)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ new Array(Number.NEGATIVE_INFINITY);
+ throw new Test262Error('#3.1: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.NEGATIVE_INFINITY)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js
new file mode 100644
index 0000000000..4acedfcaa0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js
@@ -0,0 +1,46 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is a Number and ToUint32(len) is not equal to len,
+ a RangeError exception is thrown
+es5id: 15.4.2.2_A2.2_T3
+description: Use try statement. len = 1.5, Number.MAX_VALUE, Number.MIN_VALUE
+---*/
+
+try {
+ new Array(1.5);
+ throw new Test262Error('#1.1: new Array(1.5) throw RangeError. Actual: ' + (new Array(1.5)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ new Array(Number.MAX_VALUE);
+ throw new Test262Error('#2.1: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (new Array(Number.MAX_VALUE)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ new Array(Number.MIN_VALUE);
+ throw new Test262Error('#3.1: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (new Array(Number.MIN_VALUE)));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js
new file mode 100644
index 0000000000..739b4b7537
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js
@@ -0,0 +1,24 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is not a Number, then the length property of
+ the newly constructed object is set to 1 and the 0 property of
+ the newly constructed object is set to len
+es5id: 15.4.2.2_A2.3_T1
+description: Checking for null and undefined
+---*/
+
+var x = new Array(null);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], null, 'The value of x[0] is expected to be null');
+
+var x = new Array(undefined);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js
new file mode 100644
index 0000000000..7f264fcd04
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is not a Number, then the length property of
+ the newly constructed object is set to 1 and the 0 property of
+ the newly constructed object is set to len
+es5id: 15.4.2.2_A2.3_T2
+description: Checking for boolean primitive and Boolean object
+---*/
+
+var x = new Array(true);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], true, 'The value of x[0] is expected to be true');
+
+var obj = new Boolean(false);
+var x = new Array(obj);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js
new file mode 100644
index 0000000000..4e9b4ebcdc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js
@@ -0,0 +1,25 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is not a Number, then the length property of
+ the newly constructed object is set to 1 and the 0 property of
+ the newly constructed object is set to len
+es5id: 15.4.2.2_A2.3_T3
+description: Checking for boolean primitive and Boolean object
+---*/
+
+var x = new Array("1");
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], "1", 'The value of x[0] is expected to be "1"');
+
+var obj = new String("0");
+var x = new Array(obj);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js
new file mode 100644
index 0000000000..9bc3350428
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js
@@ -0,0 +1,32 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is not a Number, then the length property of
+ the newly constructed object is set to 1 and the 0 property of
+ the newly constructed object is set to len
+es5id: 15.4.2.2_A2.3_T4
+description: Checking for Number object
+---*/
+
+var obj = new Number(0);
+var x = new Array(obj);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj');
+
+var obj = new Number(1);
+var x = new Array(obj);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj');
+
+var obj = new Number(4294967295);
+var x = new Array(obj);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js
new file mode 100644
index 0000000000..fa903f1b4c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js
@@ -0,0 +1,32 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-len
+info: |
+ If the argument len is not a Number, then the length property of
+ the newly constructed object is set to 1 and the 0 property of
+ the newly constructed object is set to len
+es5id: 15.4.2.2_A2.3_T5
+description: Checking for Number object
+---*/
+
+var obj = new Number(-1);
+var x = new Array(obj);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj');
+
+var obj = new Number(4294967296);
+var x = new Array(obj);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj');
+
+var obj = new Number(4294967297);
+var x = new Array(obj);
+
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js
new file mode 100644
index 0000000000..69898b7381
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js
@@ -0,0 +1,13 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-properties-of-the-array-prototype-object
+info: Array prototype object has a length property
+es5id: 15.4.4_A1.3_T1
+description: Array.prototype.length === 0
+---*/
+
+assert.sameValue(Array.prototype.length, 0, 'The value of Array.prototype.length is expected to be 0');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js
new file mode 100644
index 0000000000..771311678c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js
@@ -0,0 +1,47 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-exotic-objects-defineownproperty-p-desc
+info: If ToUint32(length) !== ToNumber(length), throw RangeError
+es5id: 15.4.5.1_A1.1_T1
+description: length in [4294967296, -1, 1.5]
+---*/
+
+try {
+ var x = [];
+ x.length = 4294967296;
+ throw new Test262Error('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ x = [];
+ x.length = -1;
+ throw new Test262Error('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ x = [];
+ x.length = 1.5;
+ throw new Test262Error('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js
new file mode 100644
index 0000000000..283049dbe4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js
@@ -0,0 +1,59 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-exotic-objects-defineownproperty-p-desc
+info: If ToUint32(length) !== ToNumber(length), throw RangeError
+es5id: 15.4.5.1_A1.1_T2
+description: length in [NaN, Infinity, -Infinity, undefined]
+---*/
+
+try {
+ var x = [];
+ x.length = NaN;
+ throw new Test262Error('#1.1: x = []; x.length = NaN throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ x = [];
+ x.length = Number.POSITIVE_INFINITY;
+ throw new Test262Error('#2.1: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ x = [];
+ x.length = Number.NEGATIVE_INFINITY;
+ throw new Test262Error('#3.1: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+try {
+ x = [];
+ x.length = undefined;
+ throw new Test262Error('#4.1: x = []; x.length = undefined throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ assert.sameValue(
+ e instanceof RangeError,
+ true,
+ 'The result of evaluating (e instanceof RangeError) is expected to be true'
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js
new file mode 100644
index 0000000000..9084747cae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js
@@ -0,0 +1,23 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-exotic-objects-defineownproperty-p-desc
+info: |
+ For every integer k that is less than the value of
+ the length property of A but not less than ToUint32(length),
+ if A itself has a property (not an inherited property) named ToString(k),
+ then delete that property
+es5id: 15.4.5.1_A1.2_T1
+description: Change length of array
+---*/
+
+var x = [0, , 2, , 4];
+x.length = 4;
+assert.sameValue(x[4], undefined, 'The value of x[4] is expected to equal undefined');
+
+x.length = 3;
+assert.sameValue(x[3], undefined, 'The value of x[3] is expected to equal undefined');
+assert.sameValue(x[2], 2, 'The value of x[2] is expected to be 2');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js
new file mode 100644
index 0000000000..1d3d0b9911
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js
@@ -0,0 +1,23 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-exotic-objects-defineownproperty-p-desc
+info: |
+ For every integer k that is less than the value of
+ the length property of A but not less than ToUint32(length),
+ if A itself has a property (not an inherited property) named ToString(k),
+ then delete that property
+es5id: 15.4.5.1_A1.2_T3
+description: Checking an inherited property
+---*/
+
+Array.prototype[2] = 2;
+var x = [0, 1];
+x.length = 3;
+assert.sameValue(x.hasOwnProperty('2'), false, 'x.hasOwnProperty("2") must return false');
+
+x.length = 2;
+assert.sameValue(x[2], 2, 'The value of x[2] is expected to be 2');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js
new file mode 100644
index 0000000000..711cd65564
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js
@@ -0,0 +1,35 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-exotic-objects-defineownproperty-p-desc
+info: Set the value of property length of A to Uint32(length)
+es5id: 15.4.5.1_A1.3_T1
+description: length is object or primitve
+---*/
+
+var x = [];
+x.length = true;
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+
+x = [0];
+x.length = null;
+assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0');
+
+x = [0];
+x.length = new Boolean(false);
+assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0');
+
+x = [];
+x.length = new Number(1);
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+
+x = [];
+x.length = "1";
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+
+x = [];
+x.length = new String("1");
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js
new file mode 100644
index 0000000000..c1b163c560
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js
@@ -0,0 +1,114 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array-exotic-objects-defineownproperty-p-desc
+info: Set the value of property length of A to Uint32(length)
+es5id: 15.4.5.1_A1.3_T2
+description: Uint32 use ToNumber and ToPrimitve
+---*/
+
+var x = [];
+x.length = {
+ valueOf: function() {
+ return 2
+ }
+};
+assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2');
+
+x = [];
+x.length = {
+ valueOf: function() {
+ return 2
+ },
+ toString: function() {
+ return 1
+ }
+};
+assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2');
+
+x = [];
+x.length = {
+ valueOf: function() {
+ return 2
+ },
+ toString: function() {
+ return {}
+ }
+};
+assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2');
+
+try {
+ x = [];
+ x.length = {
+ valueOf: function() {
+ return 2
+ },
+ toString: function() {
+ throw "error"
+ }
+ };
+ assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2');
+}
+catch (e) {
+ assert.notSameValue(e, "error", 'The value of e is not "error"');
+}
+
+x = [];
+x.length = {
+ toString: function() {
+ return 1
+ }
+};
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+
+x = [];
+x.length = {
+ valueOf: function() {
+ return {}
+ },
+ toString: function() {
+ return 1
+ }
+}
+assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1');
+
+try {
+ x = [];
+ x.length = {
+ valueOf: function() {
+ throw "error"
+ },
+ toString: function() {
+ return 1
+ }
+ };
+ x.length;
+ throw new Test262Error('#7.1: x = []; x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x.length throw "error". Actual: ' + (x.length));
+}
+catch (e) {
+ assert.sameValue(e, "error", 'The value of e is expected to be "error"');
+}
+
+try {
+ x = [];
+ x.length = {
+ valueOf: function() {
+ return {}
+ },
+ toString: function() {
+ return {}
+ }
+ };
+ x.length;
+ throw new Test262Error('#8.1: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return {}}} x.length throw TypeError. Actual: ' + (x.length));
+}
+catch (e) {
+ assert.sameValue(
+ e instanceof TypeError,
+ true,
+ 'The result of evaluating (e instanceof TypeError) is expected to be true'
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js b/js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js
new file mode 100644
index 0000000000..a073a7a0ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js
@@ -0,0 +1,24 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-properties-of-array-instances-length
+info: |
+ If the length property is changed, every property whose name
+ is an array index whose value is not smaller than the new length is automatically deleted
+es5id: 15.4.5.2_A3_T4
+description: >
+ If new length greater than the name of every property whose name
+ is an array index
+---*/
+
+var x = [0, 1, 2];
+x[4294967294] = 4294967294;
+x.length = 2;
+
+assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0');
+assert.sameValue(x[1], 1, 'The value of x[1] is expected to be 1');
+assert.sameValue(x[2], undefined, 'The value of x[2] is expected to equal undefined');
+assert.sameValue(x[4294967294], undefined, 'The value of x[4294967294] is expected to equal undefined');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/browser.js b/js/src/tests/test262/built-ins/Array/length/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/browser.js
diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js
new file mode 100644
index 0000000000..bb3acea2e2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: André Bargull
+esid: sec-arraysetlength
+description: >
+ [[Value]] is coerced to number before current descriptor's [[Writable]] check.
+info: |
+ ArraySetLength ( A, Desc )
+
+ [...]
+ 3. Let newLen be ? ToUint32(Desc.[[Value]]).
+ 4. Let numberLen be ? ToNumber(Desc.[[Value]]).
+ [...]
+ 7. Let oldLenDesc be OrdinaryGetOwnProperty(A, "length").
+ [...]
+ 12. If oldLenDesc.[[Writable]] is false, return false.
+features: [Symbol, Symbol.toPrimitive, Reflect, Reflect.set]
+includes: [compareArray.js]
+---*/
+
+var array = [1, 2, 3];
+var hints = [];
+var length = {};
+length[Symbol.toPrimitive] = function(hint) {
+ hints.push(hint);
+ Object.defineProperty(array, "length", {writable: false});
+ return 0;
+};
+
+assert.throws(TypeError, function() {
+ "use strict";
+ array.length = length;
+}, '`"use strict"; array.length = length` throws a TypeError exception');
+assert.compareArray(hints, ["number", "number"], 'The value of hints is expected to be ["number", "number"]');
+
+
+array = [1, 2, 3];
+hints = [];
+
+assert(
+ !Reflect.set(array, "length", length),
+ 'The value of !Reflect.set(array, "length", length) is expected to be true'
+);
+assert.compareArray(hints, ["number", "number"], 'The value of hints is expected to be ["number", "number"]');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js
new file mode 100644
index 0000000000..8c0f7a97a8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: André Bargull
+esid: sec-arraysetlength
+description: >
+ [[Value]] is coerced to number before descriptor validation.
+info: |
+ ArraySetLength ( A, Desc )
+
+ [...]
+ 3. Let newLen be ? ToUint32(Desc.[[Value]]).
+ 4. Let numberLen be ? ToNumber(Desc.[[Value]]).
+ [...]
+ 7. Let oldLenDesc be OrdinaryGetOwnProperty(A, "length").
+ [...]
+ 11. If newLen ≥ oldLen, then
+ a. Return OrdinaryDefineOwnProperty(A, "length", newLenDesc).
+
+ OrdinaryDefineOwnProperty ( O, P, Desc )
+
+ [...]
+ 3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current).
+
+ ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )
+
+ [...]
+ 7. Else if IsDataDescriptor(current) and IsDataDescriptor(Desc) are both true, then
+ a. If current.[[Configurable]] is false and current.[[Writable]] is false, then
+ i. If Desc.[[Writable]] is present and Desc.[[Writable]] is true, return false.
+features: [Reflect]
+---*/
+
+var array = [1, 2];
+var valueOfCalls = 0;
+var length = {
+ valueOf: function() {
+ valueOfCalls += 1;
+ if (valueOfCalls !== 1) {
+ // skip first coercion at step 3
+ Object.defineProperty(array, "length", {writable: false});
+ }
+ return array.length;
+ },
+};
+
+assert.throws(TypeError, function() {
+ Object.defineProperty(array, "length", {value: length, writable: true});
+}, 'Object.defineProperty(array, "length", {value: length, writable: true}) throws a TypeError exception');
+assert.sameValue(valueOfCalls, 2, 'The value of valueOfCalls is expected to be 2');
+
+
+array = [1, 2];
+valueOfCalls = 0;
+
+assert(
+ !Reflect.defineProperty(array, "length", {value: length, writable: true}),
+ 'The value of !Reflect.defineProperty(array, "length", {value: length, writable: true}) is expected to be true'
+);
+assert.sameValue(valueOfCalls, 2, 'The value of valueOfCalls is expected to be 2');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js
new file mode 100644
index 0000000000..a3122b43c6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2023 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Jordan Harband
+esid: sec-arraysetlength
+description: >
+ Setting an invalid array length throws a RangeError
+info: |
+ ArraySetLength ( A, Desc )
+
+ [...]
+ 5. If SameValueZero(newLen, numberLen) is false, throw a RangeError exception.
+ [...]
+---*/
+
+assert.throws(RangeError, function () {
+ Object.defineProperty([], 'length', { value: -1, configurable: true });
+});
+
+assert.throws(RangeError, function () {
+ // the string is intentionally "computed" here to ensure there are no optimization bugs
+ Object.defineProperty([], 'len' + 'gth', { value: -1, configurable: true });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js
new file mode 100644
index 0000000000..790a2705fe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraysetlength
+description: >
+ Ordinary descriptor validation if [[Value]] is absent.
+info: |
+ ArraySetLength ( A, Desc )
+
+ 1. If Desc.[[Value]] is absent, then
+ a. Return OrdinaryDefineOwnProperty(A, "length", Desc).
+
+ OrdinaryDefineOwnProperty ( O, P, Desc )
+
+ [...]
+ 3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current).
+
+ ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )
+
+ [...]
+ 4. If current.[[Configurable]] is false, then
+ a. If Desc.[[Configurable]] is present and its value is true, return false.
+ b. If Desc.[[Enumerable]] is present and
+ ! SameValue(Desc.[[Enumerable]], current.[[Enumerable]]) is false, return false.
+ [...]
+ 6. Else if ! SameValue(! IsDataDescriptor(current), ! IsDataDescriptor(Desc)) is false, then
+ a. If current.[[Configurable]] is false, return false.
+ [...]
+ 7. Else if IsDataDescriptor(current) and IsDataDescriptor(Desc) are both true, then
+ a. If current.[[Configurable]] is false and current.[[Writable]] is false, then
+ i. If Desc.[[Writable]] is present and Desc.[[Writable]] is true, return false.
+features: [Reflect]
+---*/
+
+assert.throws(TypeError, function() {
+ Object.defineProperty([], "length", {configurable: true});
+}, 'Object.defineProperty([], "length", {configurable: true}) throws a TypeError exception');
+
+assert(
+ !Reflect.defineProperty([], "length", {enumerable: true}),
+ 'The value of !Reflect.defineProperty([], "length", {enumerable: true}) is expected to be true'
+);
+
+assert.throws(TypeError, function() {
+ Object.defineProperty([], "length", {
+ get: function() {
+ throw new Test262Error("[[Get]] shouldn't be called");
+ },
+ });
+}, 'Object.defineProperty([], "length", {get: function() {throw new Test262Error("[[Get]] shouldn"t be called");},}) throws a TypeError exception');
+
+assert(
+ !Reflect.defineProperty([], "length", {set: function(_value) {}}),
+ 'The value of !Reflect.defineProperty([], "length", {set: function(_value) {}}) is expected to be true'
+);
+
+var array = [];
+Object.defineProperty(array, "length", {writable: false});
+assert.throws(TypeError, function() {
+ Object.defineProperty(array, "length", {writable: true});
+}, 'Object.defineProperty(array, "length", {writable: true}) throws a TypeError exception');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-order.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-order.js
new file mode 100644
index 0000000000..9cdb0d3860
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-order.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraysetlength
+description: >
+ [[Value]] is checked for overflow before descriptor validation.
+info: |
+ ArraySetLength ( A, Desc )
+
+ [...]
+ 3. Let newLen be ? ToUint32(Desc.[[Value]]).
+ 4. Let numberLen be ? ToNumber(Desc.[[Value]]).
+ 5. If newLen ≠ numberLen, throw a RangeError exception.
+---*/
+
+assert.throws(RangeError, function() {
+ Object.defineProperty([], "length", {value: -1, configurable: true});
+}, 'Object.defineProperty([], "length", {value: -1, configurable: true}) throws a RangeError exception');
+
+assert.throws(RangeError, function() {
+ Object.defineProperty([], "length", {value: NaN, enumerable: true});
+}, 'Object.defineProperty([], "length", {value: NaN, enumerable: true}) throws a RangeError exception');
+
+var array = [];
+Object.defineProperty(array, "length", {writable: false});
+assert.throws(RangeError, function() {
+ Object.defineProperty(array, "length", {value: Number.MAX_SAFE_INTEGER, writable: true});
+}, 'Object.defineProperty(array, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}) throws a RangeError exception');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-realm.js b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-realm.js
new file mode 100644
index 0000000000..67656c5f30
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-overflow-realm.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-array-exotic-objects-defineownproperty-p-desc
+es6id: 9.4.2.1
+description: >
+ Error when setting a length larger than 2**32 (honoring the Realm of the
+ current execution context)
+info: |
+ [...]
+ 2. If P is "length", then
+ a. Return ? ArraySetLength(A, Desc).
+features: [cross-realm]
+---*/
+
+var OArray = $262.createRealm().global.Array;
+var array = new OArray();
+
+assert.throws(RangeError, function() {
+ array.length = 4294967296;
+}, 'array.length = 4294967296 throws a RangeError exception');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Array/length/shell.js b/js/src/tests/test262/built-ins/Array/length/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/shell.js