summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/indexOf')
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/no-arg.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js59
43 files changed, 1628 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
new file mode 100644
index 0000000000..47b1f45d07
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14.
+
+ When the indexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return -1F.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k + 1.
+ Return -1F.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.indexOf(undefined, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
new file mode 100644
index 0000000000..320ed9a30b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14.
+
+ When the indexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return -1F.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k + 1.
+ Return -1F.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.indexOf(0n, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..84c4b0c14f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js
@@ -0,0 +1,30 @@
+// 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-%typedarray%.prototype.indexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.indexOf(0n);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js
new file mode 100644
index 0000000000..925de9d041
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js
@@ -0,0 +1,32 @@
+// 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-%typedarray%.prototype.indexof
+description: Return -1 if fromIndex >= ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA(42);
+ assert.sameValue(sample.indexOf(0n, 42), -1);
+ assert.sameValue(sample.indexOf(0n, 43), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js
new file mode 100644
index 0000000000..96251608b6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js
@@ -0,0 +1,41 @@
+// 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-%typedarray%.prototype.indexof
+description: handle Infinity values for fromIndex
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 8. Repeat, while k < len
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 43n, 41n]);
+
+ assert.sameValue(sample.indexOf(43n, Infinity), -1, "indexOf(43, Infinity)");
+ assert.sameValue(sample.indexOf(43n, -Infinity), 1, "indexOf(43, -Infinity)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..523e0a6dfb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js
@@ -0,0 +1,32 @@
+// 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-%typedarray%.prototype.indexof
+description: -0 fromIndex becomes 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n]);
+ assert.sameValue(sample.indexOf(42n, -0), 0, "-0 [0]");
+ assert.sameValue(sample.indexOf(43n, -0), 1, "-0 [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..7dd8af55a0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,34 @@
+// 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-%typedarray%.prototype.indexof
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {value: 0});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n]);
+
+ Object.defineProperty(TA.prototype, "length", {value: 0});
+ Object.defineProperty(sample, "length", {value: 0});
+
+ assert.sameValue(sample.indexOf(7n), 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js
new file mode 100644
index 0000000000..8699512769
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js
@@ -0,0 +1,39 @@
+// 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-%typedarray%.prototype.indexof
+description: Returns -1 if length is 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ 3. If len is 0, return -1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.indexOf(0n), -1, "returns -1");
+ assert.sameValue(
+ sample.indexOf(0n, fromIndex), -1,
+ "length is checked before ToInteger(fromIndex)"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/no-arg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/no-arg.js
new file mode 100644
index 0000000000..e2833a5936
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/no-arg.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-%typedarray%.prototype.indexof
+description: >
+ If `searchElement` is not supplied, -1 is returned.
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements
+ the same algorithm as Array.prototype.indexOf as defined in 22.1.3.14
+ except that the this value's [[ArrayLength]] internal slot is accessed
+ in place of performing a [[Get]] of "length".
+
+ Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ [...]
+ 10. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.indexOf(), -1);
+
+ var ta2 = new TA([0n, 1n, 2n]);
+ assert.sameValue(ta2.indexOf(), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..8a774ae4e2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.indexOf,
+ 'function',
+ 'implements TypedArray.prototype.indexOf'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.indexOf(0n);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.indexOf(0n);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the indexOf operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.indexOf(0n);
+ throw new Test262Error('indexOf completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..4d7c7950af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,34 @@
+// 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-%typedarray%.prototype.indexof
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var fromIndex = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.indexOf(7n, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..59a2d78222
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,38 @@
+// 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-%typedarray%.prototype.indexof
+description: Return abrupt from ToInteger(fromIndex)
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(Test262Error, function() {
+ sample.indexOf(7n, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js
new file mode 100644
index 0000000000..70c5d26c8e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js
@@ -0,0 +1,48 @@
+// 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-%typedarray%.prototype.indexof
+description: returns index for the first found element
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 8. Repeat, while k < len
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 42n, 41n]);
+ assert.sameValue(sample.indexOf(42n), 0, "indexOf(42)");
+ assert.sameValue(sample.indexOf(43n), 1, "indexOf(43)");
+ assert.sameValue(sample.indexOf(43n, 1), 1, "indexOf(43, 1)");
+ assert.sameValue(sample.indexOf(42n, 1), 2, "indexOf(42, 1)");
+ assert.sameValue(sample.indexOf(42n, 2), 2, "indexOf(42, 2)");
+
+ assert.sameValue(sample.indexOf(42n, -4), 0, "indexOf(42, -4)");
+ assert.sameValue(sample.indexOf(42n, -3), 2, "indexOf(42, -3)");
+ assert.sameValue(sample.indexOf(42n, -2), 2, "indexOf(42, -2)");
+ assert.sameValue(sample.indexOf(42n, -5), 0, "indexOf(42, -5)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js
new file mode 100644
index 0000000000..bb62c56ffe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js
@@ -0,0 +1,40 @@
+// 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-%typedarray%.prototype.indexof
+description: returns -1 if the element if not found
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ ...
+ 9. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n, 42n, 41n]);
+ assert.sameValue(sample.indexOf(44n), -1, "indexOf(44)");
+ assert.sameValue(sample.indexOf(43n, 2), -1, "indexOf(43, 2)");
+ assert.sameValue(sample.indexOf(42n, 3), -1, "indexOf(42, 3)");
+ assert.sameValue(sample.indexOf(44n, -4), -1, "indexOf(44, -4)");
+ assert.sameValue(sample.indexOf(44n, -5), -1, "indexOf(44, -5)");
+ assert.sameValue(sample.indexOf(42n, -1), -1, "indexOf(42, -1)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Collection of functions used to assert the correctness of BigInt TypedArray objects.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ for (var i = 0; i < constructors.length; ++i) {
+ var constructor = constructors[i];
+ try {
+ f(constructor);
+ } catch (e) {
+ e.message += " (Testing with " + constructor.name + ".)";
+ throw e;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js
new file mode 100644
index 0000000000..7f141f9ef0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js
@@ -0,0 +1,59 @@
+// 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-%typedarray%.prototype.indexof
+description: Return -1 if fromIndex >= ArrayLength - converted values
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n]);
+ assert.sameValue(sample.indexOf(42n, "1"), -1, "string [0]");
+ assert.sameValue(sample.indexOf(43n, "1"), 1, "string [1]");
+
+ assert.sameValue(sample.indexOf(42n, true), -1, "true [0]");
+ assert.sameValue(sample.indexOf(43n, true), 1, "true [1]");
+
+ assert.sameValue(sample.indexOf(42n, false), 0, "false [0]");
+ assert.sameValue(sample.indexOf(43n, false), 1, "false [1]");
+
+ assert.sameValue(sample.indexOf(42n, NaN), 0, "NaN [0]");
+ assert.sameValue(sample.indexOf(43n, NaN), 1, "NaN [1]");
+
+ assert.sameValue(sample.indexOf(42n, null), 0, "null [0]");
+ assert.sameValue(sample.indexOf(43n, null), 1, "null [1]");
+
+ assert.sameValue(sample.indexOf(42n, undefined), 0, "undefined [0]");
+ assert.sameValue(sample.indexOf(43n, undefined), 1, "undefined [1]");
+
+ assert.sameValue(sample.indexOf(42n, null), 0, "null [0]");
+ assert.sameValue(sample.indexOf(43n, null), 1, "null [1]");
+
+ assert.sameValue(sample.indexOf(42n, obj), -1, "object [0]");
+ assert.sameValue(sample.indexOf(43n, obj), 1, "object [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
new file mode 100644
index 0000000000..7081b55ed5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14.
+
+ When the indexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return -1F.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k + 1.
+ Return -1F.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.indexOf(undefined, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
new file mode 100644
index 0000000000..8fff2cbb75
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14.
+
+ When the indexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return -1F.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k + 1.
+ Return -1F.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.indexOf(0, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js
new file mode 100644
index 0000000000..60c374ad87
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js
@@ -0,0 +1,30 @@
+// 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-%typedarray%.prototype.indexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.indexOf(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js
new file mode 100644
index 0000000000..de345d49a2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js
@@ -0,0 +1,32 @@
+// 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-%typedarray%.prototype.indexof
+description: Return -1 if fromIndex >= ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA(42);
+ assert.sameValue(sample.indexOf(0, 42), -1);
+ assert.sameValue(sample.indexOf(0, 43), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js
new file mode 100644
index 0000000000..1f75f72769
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js
@@ -0,0 +1,41 @@
+// 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-%typedarray%.prototype.indexof
+description: handle Infinity values for fromIndex
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 8. Repeat, while k < len
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 43, 41]);
+
+ assert.sameValue(sample.indexOf(43, Infinity), -1, "indexOf(43, Infinity)");
+ assert.sameValue(sample.indexOf(43, -Infinity), 1, "indexOf(43, -Infinity)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..6bd0d4b447
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js
@@ -0,0 +1,32 @@
+// 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-%typedarray%.prototype.indexof
+description: -0 fromIndex becomes 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43]);
+ assert.sameValue(sample.indexOf(42, -0), 0, "-0 [0]");
+ assert.sameValue(sample.indexOf(43, -0), 1, "-0 [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..04738cec2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js
@@ -0,0 +1,34 @@
+// 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-%typedarray%.prototype.indexof
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {value: 0});
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7]);
+
+ Object.defineProperty(TA.prototype, "length", {value: 0});
+ Object.defineProperty(sample, "length", {value: 0});
+
+ assert.sameValue(sample.indexOf(7), 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js
new file mode 100644
index 0000000000..84ca275587
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js
@@ -0,0 +1,31 @@
+// 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-%typedarray%.prototype.indexof
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var indexOf = TypedArray.prototype.indexOf;
+
+assert.sameValue(typeof indexOf, 'function');
+
+assert.throws(TypeError, function() {
+ indexOf();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js
new file mode 100644
index 0000000000..a0617fd2a2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js
@@ -0,0 +1,31 @@
+// 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-%typedarray%.prototype.indexof
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.indexOf, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.indexOf();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js
new file mode 100644
index 0000000000..37163cf2aa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js
@@ -0,0 +1,39 @@
+// 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-%typedarray%.prototype.indexof
+description: Returns -1 if length is 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ 3. If len is 0, return -1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.indexOf(0), -1, "returns -1");
+ assert.sameValue(
+ sample.indexOf(0, fromIndex), -1,
+ "length is checked before ToInteger(fromIndex)"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js
new file mode 100644
index 0000000000..5c866bebad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: >
+ %TypedArray%.prototype.indexOf.length is 1.
+info: |
+ %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.indexOf.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.indexOf, "length");
+verifyNotWritable(TypedArray.prototype.indexOf, "length");
+verifyConfigurable(TypedArray.prototype.indexOf, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js
new file mode 100644
index 0000000000..54aea8a605
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: >
+ %TypedArray%.prototype.indexOf.name is "indexOf".
+info: |
+ %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.indexOf.name, "indexOf");
+
+verifyNotEnumerable(TypedArray.prototype.indexOf, "name");
+verifyNotWritable(TypedArray.prototype.indexOf, "name");
+verifyConfigurable(TypedArray.prototype.indexOf, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js
new file mode 100644
index 0000000000..57015f26c9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.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-%typedarray%.prototype.indexof
+description: >
+ If `searchElement` is not supplied, -1 is returned.
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements
+ the same algorithm as Array.prototype.indexOf as defined in 22.1.3.14
+ except that the this value's [[ArrayLength]] internal slot is accessed
+ in place of performing a [[Get]] of "length".
+
+ Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ [...]
+ 10. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.indexOf(), -1);
+
+ var ta2 = new TA([0, 1, 2]);
+ assert.sameValue(ta2.indexOf(), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js
new file mode 100644
index 0000000000..7ada33c348
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.indexOf does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.indexOf),
+ false,
+ 'isConstructor(TypedArray.prototype.indexOf) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.indexOf();
+}, '`let u8 = new Uint8Array(1); new u8.indexOf()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js
new file mode 100644
index 0000000000..be05ced431
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js
@@ -0,0 +1,21 @@
+// 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-%typedarray%.prototype.indexof
+description: >
+ "indexOf" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'indexOf');
+verifyWritable(TypedArrayPrototype, 'indexOf');
+verifyConfigurable(TypedArrayPrototype, 'indexOf');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..ec11f3167c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.indexOf,
+ 'function',
+ 'implements TypedArray.prototype.indexOf'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.indexOf(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.indexOf(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the indexOf operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.indexOf(0);
+ throw new Test262Error('indexOf completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..21820e40ae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,34 @@
+// 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-%typedarray%.prototype.indexof
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var fromIndex = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.indexOf(7, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..7789414bdc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,38 @@
+// 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-%typedarray%.prototype.indexof
+description: Return abrupt from ToInteger(fromIndex)
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(Test262Error, function() {
+ sample.indexOf(7, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js
new file mode 100644
index 0000000000..810caadd88
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js
@@ -0,0 +1,48 @@
+// 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-%typedarray%.prototype.indexof
+description: returns index for the first found element
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 8. Repeat, while k < len
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 42, 41]);
+ assert.sameValue(sample.indexOf(42), 0, "indexOf(42)");
+ assert.sameValue(sample.indexOf(43), 1, "indexOf(43)");
+ assert.sameValue(sample.indexOf(43, 1), 1, "indexOf(43, 1)");
+ assert.sameValue(sample.indexOf(42, 1), 2, "indexOf(42, 1)");
+ assert.sameValue(sample.indexOf(42, 2), 2, "indexOf(42, 2)");
+
+ assert.sameValue(sample.indexOf(42, -4), 0, "indexOf(42, -4)");
+ assert.sameValue(sample.indexOf(42, -3), 2, "indexOf(42, -3)");
+ assert.sameValue(sample.indexOf(42, -2), 2, "indexOf(42, -2)");
+ assert.sameValue(sample.indexOf(42, -5), 0, "indexOf(42, -5)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js
new file mode 100644
index 0000000000..e270f87c37
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js
@@ -0,0 +1,40 @@
+// 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-%typedarray%.prototype.indexof
+description: returns -1 if the element if not found
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ ...
+ 9. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43, 42, 41]);
+ assert.sameValue(sample.indexOf(44), -1, "indexOf(44)");
+ assert.sameValue(sample.indexOf(43, 2), -1, "indexOf(43, 2)");
+ assert.sameValue(sample.indexOf(42, 3), -1, "indexOf(42, 3)");
+ assert.sameValue(sample.indexOf(44, -4), -1, "indexOf(44, -4)");
+ assert.sameValue(sample.indexOf(44, -5), -1, "indexOf(44, -5)");
+ assert.sameValue(sample.indexOf(42, -1), -1, "indexOf(42, -1)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js
new file mode 100644
index 0000000000..64e9e774e5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js
@@ -0,0 +1,43 @@
+// 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-%typedarray%.prototype.indexof
+description: search element is compared using strict comparing (===)
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 0, 1, undefined, NaN]);
+ assert.sameValue(sample.indexOf("42"), -1, "'42'");
+ assert.sameValue(sample.indexOf([42]), -1, "[42]");
+ assert.sameValue(sample.indexOf(42.0), 0, "42.0");
+ assert.sameValue(sample.indexOf(-0), 1, "-0");
+ assert.sameValue(sample.indexOf(true), -1, "true");
+ assert.sameValue(sample.indexOf(false), -1, "false");
+ assert.sameValue(sample.indexOf(NaN), -1, "NaN === NaN is false");
+ assert.sameValue(sample.indexOf(null), -1, "null");
+ assert.sameValue(sample.indexOf(undefined), -1, "undefined");
+ assert.sameValue(sample.indexOf(""), -1, "empty string");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js
new file mode 100644
index 0000000000..9bb19be858
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js
@@ -0,0 +1,52 @@
+// 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-%typedarray%.prototype.indexof
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var indexOf = TypedArray.prototype.indexOf;
+
+assert.throws(TypeError, function() {
+ indexOf.call(undefined, 42);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ indexOf.call(null, 42);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ indexOf.call(42, 42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ indexOf.call("1", 42);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ indexOf.call(true, 42);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ indexOf.call(false, 42);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ indexOf.call(s, 42);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..22fff52e60
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// 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-%typedarray%.prototype.indexof
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var indexOf = TypedArray.prototype.indexOf;
+
+assert.throws(TypeError, function() {
+ indexOf.call({}, 42);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ indexOf.call([], 42);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ indexOf.call(ab, 42);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ indexOf.call(dv, 42);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js
new file mode 100644
index 0000000000..07f6808fdc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js
@@ -0,0 +1,59 @@
+// 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-%typedarray%.prototype.indexof
+description: Return -1 if fromIndex >= ArrayLength - converted values
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43]);
+ assert.sameValue(sample.indexOf(42, "1"), -1, "string [0]");
+ assert.sameValue(sample.indexOf(43, "1"), 1, "string [1]");
+
+ assert.sameValue(sample.indexOf(42, true), -1, "true [0]");
+ assert.sameValue(sample.indexOf(43, true), 1, "true [1]");
+
+ assert.sameValue(sample.indexOf(42, false), 0, "false [0]");
+ assert.sameValue(sample.indexOf(43, false), 1, "false [1]");
+
+ assert.sameValue(sample.indexOf(42, NaN), 0, "NaN [0]");
+ assert.sameValue(sample.indexOf(43, NaN), 1, "NaN [1]");
+
+ assert.sameValue(sample.indexOf(42, null), 0, "null [0]");
+ assert.sameValue(sample.indexOf(43, null), 1, "null [1]");
+
+ assert.sameValue(sample.indexOf(42, undefined), 0, "undefined [0]");
+ assert.sameValue(sample.indexOf(43, undefined), 1, "undefined [1]");
+
+ assert.sameValue(sample.indexOf(42, null), 0, "null [0]");
+ assert.sameValue(sample.indexOf(43, null), 1, "null [1]");
+
+ assert.sameValue(sample.indexOf(42, obj), -1, "object [0]");
+ assert.sameValue(sample.indexOf(43, obj), 1, "object [1]");
+});
+
+reportCompare(0, 0);