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-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/built-ins/Array/length
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
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.js23
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js21
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js19
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.js18
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js31
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js43
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js38
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js39
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js53
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js53
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js16
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js44
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js55
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js33
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js29
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js53
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js138
-rw-r--r--js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js40
-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.js45
-rw-r--r--js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js60
-rw-r--r--js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js58
-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
31 files changed, 1137 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..a72f4ce727
--- /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;
+});
+
+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..0a3bfcfe6f
--- /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;
+});
+
+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..af8ec6f601
--- /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, 'a.length');
+
+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..1d5559b38d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_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-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
+---*/
+
+//CHECK#1
+Array.prototype.myproperty = 1;
+var x = new Array(0);
+if (x.myproperty !== 1) {
+ $ERROR('#1: Array.prototype.myproperty = 1; var x = new Array(0); x.myproperty === 1. Actual: ' + (x.myproperty));
+}
+
+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..e97227c1dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T2.js
@@ -0,0 +1,21 @@
+// 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
+---*/
+
+//CHECK#1
+Array.prototype.toString = Object.prototype.toString;
+var x = new Array(0);
+if (x.toString() !== "[object " + "Array" + "]") {
+ $ERROR('#1: Array.prototype.toString = Object.prototype.toString; var x = new Array(0); x.toString() === "[object " + "Array" + "]". Actual: ' + (x.toString()));
+}
+
+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..f686040180
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.1_T3.js
@@ -0,0 +1,19 @@
+// 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
+---*/
+
+//CHECK#1
+if (Array.prototype.isPrototypeOf(new Array(0)) !== true) {
+ $ERROR('#1: Array.prototype.isPrototypeOf(new Array(0)) === true. Actual: ' + (Array.prototype.isPrototypeOf(new Array(0))));
+}
+
+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..5cf69c6cd8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A1.2_T1.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 [[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
+---*/
+
+//CHECK#1
+var x = new Array(0);
+x.getClass = Object.prototype.toString;
+if (x.getClass() !== "[object " + "Array" + "]") {
+ $ERROR('#1: var x = new Array(0); x.getClass = Object.prototype.toString; x is Array object. Actual: ' + (x.getClass()));
+}
+
+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..a93c3e1cd6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.1_T1.js
@@ -0,0 +1,31 @@
+// 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
+---*/
+
+//CHECK#1
+var x = new Array(0);
+if (x.length !== 0) {
+ $ERROR('#1: var x = new Array(0); x.length === 0. Actual: ' + (x.length));
+}
+
+//CHECK#2
+var x = new Array(1);
+if (x.length !== 1) {
+ $ERROR('#2: var x = new Array(1); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#3
+var x = new Array(4294967295);
+if (x.length !== 4294967295) {
+ $ERROR('#3: var x = new Array(4294967295); x.length === 4294967295. Actual: ' + (x.length));
+}
+
+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..acf5afbbfd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T1.js
@@ -0,0 +1,43 @@
+// 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
+---*/
+
+//CHECK#1
+try {
+ new Array(-1);
+ $ERROR('#1.1: new Array(-1) throw RangeError. Actual: ' + (new Array(-1)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#1.2: new Array(-1) throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#2
+try {
+ new Array(4294967296);
+ $ERROR('#2.1: new Array(4294967296) throw RangeError. Actual: ' + (new Array(4294967296)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#2.2: new Array(4294967296) throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#3
+try {
+ new Array(4294967297);
+ $ERROR('#3.1: new Array(4294967297) throw RangeError. Actual: ' + (new Array(4294967297)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#3.2: new Array(4294967297) throw RangeError. Actual: ' + (e));
+ }
+}
+
+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..7c3cf7ba2e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T2.js
@@ -0,0 +1,43 @@
+// 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
+---*/
+
+//CHECK#1
+try {
+ new Array(NaN);
+ $ERROR('#1.1: new Array(NaN) throw RangeError. Actual: ' + (new Array(NaN)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#1.2: new Array(NaN) throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#2
+try {
+ new Array(Number.POSITIVE_INFINITY);
+ $ERROR('#2.1: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.POSITIVE_INFINITY)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#2.2: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#3
+try {
+ new Array(Number.NEGATIVE_INFINITY);
+ $ERROR('#3.1: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (new Array(Number.NEGATIVE_INFINITY)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#3.2: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (e));
+ }
+}
+
+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..109246ca10
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.2_T3.js
@@ -0,0 +1,43 @@
+// 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
+---*/
+
+//CHECK#1
+try {
+ new Array(1.5);
+ $ERROR('#1.1: new Array(1.5) throw RangeError. Actual: ' + (new Array(1.5)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#1.2: new Array(1.5) throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#2
+try {
+ new Array(Number.MAX_VALUE);
+ $ERROR('#2.1: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (new Array(Number.MAX_VALUE)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#2.2: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#3
+try {
+ new Array(Number.MIN_VALUE);
+ $ERROR('#3.1: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (new Array(Number.MIN_VALUE)));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#3.2: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (e));
+ }
+}
+
+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..8fee44e419
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T1.js
@@ -0,0 +1,38 @@
+// 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);
+
+//CHECK#1
+if (x.length !== 1) {
+ $ERROR('#1: var x = new Array(null); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#2
+if (x[0] !== null) {
+ $ERROR('#2: var x = new Array(null); x[0] === null. Actual: ' + (x[0]));
+}
+
+var x = new Array(undefined);
+
+//CHECK#3
+if (x.length !== 1) {
+ $ERROR('#3: var x = new Array(undefined); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#4
+if (x[0] !== undefined) {
+ $ERROR('#4: var x = new Array(undefined); x[0] === undefined. Actual: ' + (x[0]));
+}
+
+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..0f1c2f5e24
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T2.js
@@ -0,0 +1,39 @@
+// 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);
+
+//CHECK#1
+if (x.length !== 1) {
+ $ERROR('#1: var x = new Array(true); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#2
+if (x[0] !== true) {
+ $ERROR('#2: var x = new Array(true); x[0] === true. Actual: ' + (x[0]));
+}
+
+var obj = new Boolean(false);
+var x = new Array(obj);
+
+//CHECK#3
+if (x.length !== 1) {
+ $ERROR('#3: var obj = new Boolean(false); var x = new Array(obj); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#4
+if (x[0] !== obj) {
+ $ERROR('#4: var obj = new Boolean(false); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0]));
+}
+
+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..b29d18c062
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T3.js
@@ -0,0 +1,39 @@
+// 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");
+
+//CHECK#1
+if (x.length !== 1) {
+ $ERROR('#1: var x = new Array("1"); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#2
+if (x[0] !== "1") {
+ $ERROR('#2: var x = new Array("1"); x[0] === "1". Actual: ' + (x[0]));
+}
+
+var obj = new String("0");
+var x = new Array(obj);
+
+//CHECK#3
+if (x.length !== 1) {
+ $ERROR('#3: var obj = new String("0"); var x = new Array(obj); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#4
+if (x[0] !== obj) {
+ $ERROR('#4: var obj = new String("0"); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0]));
+}
+
+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..05cd3d6e38
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T4.js
@@ -0,0 +1,53 @@
+// 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);
+
+//CHECK#1
+if (x.length !== 1) {
+ $ERROR('#1: var obj = new Number(0); var x = new Array(obj); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#2
+if (x[0] !== obj) {
+ $ERROR('#2: var obj = new Number(0); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0]));
+}
+
+var obj = new Number(1);
+var x = new Array(obj);
+
+//CHECK#3
+if (x.length !== 1) {
+ $ERROR('#3: var obj = new Number(1); var x = new Array(obj); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#4
+if (x[0] !== obj) {
+ $ERROR('#4: var obj = new Number(1); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0]));
+}
+
+var obj = new Number(4294967295);
+var x = new Array(obj);
+
+//CHECK#5
+if (x.length !== 1) {
+ $ERROR('#5: var obj = new Number(4294967295); var x = new Array(obj); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#6
+if (x[0] !== obj) {
+ $ERROR('#6: var obj = new Number(4294967295); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0]));
+}
+
+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..339f24d024
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.2.2_A2.3_T5.js
@@ -0,0 +1,53 @@
+// 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);
+
+//CHECK#1
+if (x.length !== 1) {
+ $ERROR('#1: var obj = new Number(-1); var x = new Array(obj); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#2
+if (x[0] !== obj) {
+ $ERROR('#2: var obj = new Number(-1); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0]));
+}
+
+var obj = new Number(4294967296);
+var x = new Array(obj);
+
+//CHECK#3
+if (x.length !== 1) {
+ $ERROR('#3: var obj = new Number(4294967296); var x = new Array(obj); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#4
+if (x[0] !== obj) {
+ $ERROR('#4: var obj = new Number(4294967296); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0]));
+}
+
+var obj = new Number(4294967297);
+var x = new Array(obj);
+
+//CHECK#5
+if (x.length !== 1) {
+ $ERROR('#5: var obj = new Number(4294967297); var x = new Array(obj); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#6
+if (x[0] !== obj) {
+ $ERROR('#6: var obj = new Number(4294967297); var x = new Array(obj); x[0] === obj. Actual: ' + (x[0]));
+}
+
+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..705139aa3b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.4_A1.3_T1.js
@@ -0,0 +1,16 @@
+// 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
+---*/
+
+//CHECK#1
+if (Array.prototype.length !== 0) {
+ $ERROR('#1.1: Array.prototype.length === 0. Actual: ' + (Array.prototype.length));
+}
+
+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..6ccfdfd0fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T1.js
@@ -0,0 +1,44 @@
+// 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]
+---*/
+
+//CHECK#1
+try {
+ var x = [];
+ x.length = 4294967296;
+ $ERROR('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#1.2: x = []; x.length = 4294967296 throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#2
+try {
+ x = [];
+ x.length = -1;
+ $ERROR('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#2.2: x = []; x.length = -1 throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#3
+try {
+ x = [];
+ x.length = 1.5;
+ $ERROR('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#3.2: x = []; x.length = 1.5 throw RangeError. Actual: ' + (e));
+ }
+}
+
+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..ad1d408417
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.1_T2.js
@@ -0,0 +1,55 @@
+// 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]
+---*/
+
+//CHECK#1
+try {
+ var x = [];
+ x.length = NaN;
+ $ERROR('#1.1: x = []; x.length = NaN throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#1.2: x = []; x.length = NaN throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#2
+try {
+ x = [];
+ x.length = Number.POSITIVE_INFINITY;
+ $ERROR('#2.1: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#2.2: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#3
+try {
+ x = [];
+ x.length = Number.NEGATIVE_INFINITY;
+ $ERROR('#3.1: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#3.2: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: ' + (e));
+ }
+}
+
+//CHECK#4
+try {
+ x = [];
+ x.length = undefined;
+ $ERROR('#4.1: x = []; x.length = undefined throw RangeError. Actual: x.length === ' + (x.length));
+} catch (e) {
+ if ((e instanceof RangeError) !== true) {
+ $ERROR('#4.2: x = []; x.length = undefined throw RangeError. Actual: ' + (e));
+ }
+}
+
+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..eb32f26370
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T1.js
@@ -0,0 +1,33 @@
+// 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
+---*/
+
+//CHECK#1
+var x = [0, , 2, , 4];
+x.length = 4;
+if (x[4] !== undefined) {
+ $ERROR('#1: x = [0,,2,,4]; x.length = 4; x[4] === undefined. Actual: ' + (x[4]));
+}
+
+//CHECK#2
+x.length = 3;
+if (x[3] !== undefined) {
+ $ERROR('#2: x = [0,,2,,4]; x.length = 4; x.length = 3; x[3] === undefined. Actual: ' + (x[3]));
+}
+
+//CHECK#3
+if (x[2] !== 2) {
+ $ERROR('#3: x = [0,,2,,4]; x.length = 4; x.length = 3; x[2] === 2. Actual: ' + (x[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..1944a52f9c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.2_T3.js
@@ -0,0 +1,29 @@
+// 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
+---*/
+
+//CHECK#1
+Array.prototype[2] = 2;
+var x = [0, 1];
+x.length = 3;
+if (x.hasOwnProperty('2') !== false) {
+ $ERROR('#1: Array.prototype[2] = 2; x = [0,1]; x.length = 3; x.hasOwnProperty(\'2\') === false. Actual: ' + (x.hasOwnProperty('2')));
+}
+
+//CHECK#2
+x.length = 2;
+if (x[2] !== 2) {
+ $ERROR('#2: Array.prototype[2] = 2; x = [0,1]; x.length = 3; x.length = 2; x[2] === 2. Actual: ' + (x[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..cb50bc0cb7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T1.js
@@ -0,0 +1,53 @@
+// 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
+---*/
+
+//CHECK#1
+var x = [];
+x.length = true;
+if (x.length !== 1) {
+ $ERROR('#1: x = []; x.length = true; x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#2
+x = [0];
+x.length = null;
+if (x.length !== 0) {
+ $ERROR('#2: x = [0]; x.length = null; x.length === 0. Actual: ' + (x.length));
+}
+
+//CHECK#3
+x = [0];
+x.length = new Boolean(false);
+if (x.length !== 0) {
+ $ERROR('#3: x = [0]; x.length = new Boolean(false); x.length === 0. Actual: ' + (x.length));
+}
+
+//CHECK#4
+x = [];
+x.length = new Number(1);
+if (x.length !== 1) {
+ $ERROR('#4: x = []; x.length = new Number(1); x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#5
+x = [];
+x.length = "1";
+if (x.length !== 1) {
+ $ERROR('#5: x = []; x.length = "1"; x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#6
+x = [];
+x.length = new String("1");
+if (x.length !== 1) {
+ $ERROR('#6: x = []; x.length = new String("1"); x.length === 1. Actual: ' + (x.length));
+}
+
+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..e03a8318d9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.1_A1.3_T2.js
@@ -0,0 +1,138 @@
+// 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
+---*/
+
+//CHECK#1
+var x = [];
+x.length = {
+ valueOf: function() {
+ return 2
+ }
+};
+if (x.length !== 2) {
+ $ERROR('#1: x = []; x.length = {valueOf: function() {return 2}}; x.length === 2. Actual: ' + (x.length));
+}
+
+//CHECK#2
+x = [];
+x.length = {
+ valueOf: function() {
+ return 2
+ },
+ toString: function() {
+ return 1
+ }
+};
+if (x.length !== 2) {
+ $ERROR('#0: x = []; x.length = {valueOf: function() {return 2}, toString: function() {return 1}}; x.length === 2. Actual: ' + (x.length));
+}
+
+//CHECK#3
+x = [];
+x.length = {
+ valueOf: function() {
+ return 2
+ },
+ toString: function() {
+ return {}
+ }
+};
+if (x.length !== 2) {
+ $ERROR('#3: x = []; x.length = {valueOf: function() {return 2}, toString: function() {return {}}}; x.length === 2. Actual: ' + (x.length));
+}
+
+//CHECK#4
+try {
+ x = [];
+ x.length = {
+ valueOf: function() {
+ return 2
+ },
+ toString: function() {
+ throw "error"
+ }
+ };
+ if (x.length !== 2) {
+ $ERROR('#4.1: x = []; x.length = {valueOf: function() {return 2}, toString: function() {throw "error"}}; x.length === ",". Actual: ' + (x.length));
+ }
+}
+catch (e) {
+ if (e === "error") {
+ $ERROR('#4.2: x = []; x.length = {valueOf: function() {return 2}, toString: function() {throw "error"}}; x.length not throw "error"');
+ } else {
+ $ERROR('#4.3: x = []; x.length = {valueOf: function() {return 2}, toString: function() {throw "error"}}; x.length not throw Error. Actual: ' + (e));
+ }
+}
+
+//CHECK#5
+x = [];
+x.length = {
+ toString: function() {
+ return 1
+ }
+};
+if (x.length !== 1) {
+ $ERROR('#5: x = []; x.length = {toString: function() {return 1}}; x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#6
+x = [];
+x.length = {
+ valueOf: function() {
+ return {}
+ },
+ toString: function() {
+ return 1
+ }
+}
+if (x.length !== 1) {
+ $ERROR('#6: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return 1}}; x.length === 1. Actual: ' + (x.length));
+}
+
+//CHECK#7
+try {
+ x = [];
+ x.length = {
+ valueOf: function() {
+ throw "error"
+ },
+ toString: function() {
+ return 1
+ }
+ };
+ x.length;
+ $ERROR('#7.1: x = []; x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x.length throw "error". Actual: ' + (x.length));
+}
+catch (e) {
+ if (e !== "error") {
+ $ERROR('#7.2: x = []; x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x.length throw "error". Actual: ' + (e));
+ }
+}
+
+//CHECK#8
+try {
+ x = [];
+ x.length = {
+ valueOf: function() {
+ return {}
+ },
+ toString: function() {
+ return {}
+ }
+ };
+ x.length;
+ $ERROR('#8.1: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return {}}} x.length throw TypeError. Actual: ' + (x.length));
+}
+catch (e) {
+ if ((e instanceof TypeError) !== true) {
+ $ERROR('#8.2: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return {}}} x.length throw TypeError. Actual: ' + (e));
+ }
+}
+
+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..542692f386
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/S15.4.5.2_A3_T4.js
@@ -0,0 +1,40 @@
+// 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
+---*/
+
+//CHECK#1
+var x = [0, 1, 2];
+x[4294967294] = 4294967294;
+x.length = 2;
+
+//CHECK#1
+if (x[0] !== 0) {
+ $ERROR('#1: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[0] === 0. Actual: ' + (x[0]));
+}
+
+//CHECK#2
+if (x[1] !== 1) {
+ $ERROR('#2: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[1] === 1. Actual: ' + (x[1]));
+}
+
+//CHECK#3
+if (x[2] !== undefined) {
+ $ERROR('#3: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[2] === undefined. Actual: ' + (x[2]));
+}
+
+//CHECK#4
+if (x[4294967294] !== undefined) {
+ $ERROR('#4: x = [0,1,2]; x[4294967294] = 4294967294; x.length = 2; x[4294967294] === undefined. Actual: ' + (x[4294967294]));
+}
+
+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..a933348825
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order-set.js
@@ -0,0 +1,45 @@
+// 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;
+});
+assert.compareArray(hints, ["number", "number"]);
+
+
+array = [1, 2, 3];
+hints = [];
+
+assert(!Reflect.set(array, "length", length));
+assert.compareArray(hints, ["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..81dc7cd163
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-coercion-order.js
@@ -0,0 +1,60 @@
+// 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});
+});
+assert.sameValue(valueOfCalls, 2);
+
+
+array = [1, 2];
+valueOfCalls = 0;
+
+assert(!Reflect.defineProperty(array, "length", {value: length, writable: true}));
+assert.sameValue(valueOfCalls, 2);
+
+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..aa39ae4236
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/length/define-own-prop-length-no-value-order.js
@@ -0,0 +1,58 @@
+// 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});
+});
+
+assert(!Reflect.defineProperty([], "length", {enumerable: true}));
+
+assert.throws(TypeError, function() {
+ Object.defineProperty([], "length", {
+ get: function() {
+ throw new Test262Error("[[Get]] shouldn't be called");
+ },
+ });
+});
+
+assert(!Reflect.defineProperty([], "length", {set: function(_value) {}}));
+
+var array = [];
+Object.defineProperty(array, "length", {writable: false});
+assert.throws(TypeError, function() {
+ Object.defineProperty(array, "length", {writable: true});
+});
+
+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..7e9b345fcf
--- /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});
+});
+
+assert.throws(RangeError, function() {
+ Object.defineProperty([], "length", {value: NaN, enumerable: true});
+});
+
+var array = [];
+Object.defineProperty(array, "length", {writable: false});
+assert.throws(RangeError, function() {
+ Object.defineProperty(array, "length", {value: Number.MAX_SAFE_INTEGER, writable: true});
+});
+
+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..565de0b0e7
--- /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;
+});
+
+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