summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArrays/ctors/object-arg
diff options
context:
space:
mode:
Diffstat (limited to 'test/built-ins/TypedArrays/ctors/object-arg')
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-array-returns.js28
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-generator-iterable-returns.js30
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation-consistent-nan.js61
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation.js53
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-custom-proto-access-throws.js48
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterating-throws.js31
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-not-callable-throws.js39
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-throws.js34
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-excessive-throws.js30
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-is-symbol-throws.js30
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-throws.js34
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-new-instance-extensibility.js43
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-proto-from-ctor-realm.js37
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-returns.js45
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-from-property.js38
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js77
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive.js75
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-tostring.js88
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js89
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof.js82
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-property.js38
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-symbol-property.js34
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-undefined-newtarget-throws.js30
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-custom-proto-if-object.js47
-rw-r--r--test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js47
25 files changed, 1188 insertions, 0 deletions
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-array-returns.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-array-returns.js
new file mode 100644
index 000000000..a5e3c3bbc
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-array-returns.js
@@ -0,0 +1,28 @@
+// 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-object
+description: >
+ Return typedArray from array argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = [7, 42];
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(obj);
+ assert.sameValue(typedArray.length, 2);
+ assert.sameValue(typedArray[0], 7);
+ assert.sameValue(typedArray[1], 42);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-generator-iterable-returns.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-generator-iterable-returns.js
new file mode 100644
index 000000000..f9af0defe
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-generator-iterable-returns.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-object
+description: >
+ Return typedArray from iterable argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var obj = (function *() {
+ yield 7; yield 42;
+ })();
+
+ var typedArray = new TA(obj);
+ assert.sameValue(typedArray.length, 2);
+ assert.sameValue(typedArray[0], 7);
+ assert.sameValue(typedArray[1], 42);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation-consistent-nan.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation-consistent-nan.js
new file mode 100644
index 000000000..d01684942
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation-consistent-nan.js
@@ -0,0 +1,61 @@
+// 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-object
+description: Consistent canonicalization of NaN values
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
+ ...
+
+ 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
+ isLittleEndian ] )
+
+ ...
+ 8. If type is "Float32", then
+ a. Set rawBytes to a List containing the 4 bytes that are the result
+ of converting value to IEEE 754-2008 binary32 format using “Round to
+ nearest, ties to even” rounding mode. If isLittleEndian is false, the
+ bytes are arranged in big endian order. Otherwise, the bytes are
+ arranged in little endian order. If value is NaN, rawValue may be set
+ to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number
+ encoding. An implementation must always choose the same encoding for
+ each implementation distinguishable NaN value.
+ 9. Else, if type is "Float64", then
+ a. Set rawBytes to a List containing the 8 bytes that are the IEEE
+ 754-2008 binary64 format encoding of value. If isLittleEndian is false,
+ the bytes are arranged in big endian order. Otherwise, the bytes are
+ arranged in little endian order. If value is NaN, rawValue may be set
+ to any implementation chosen IEEE 754-2008 binary32 format Not-a-Number
+ encoding. An implementation must always choose the same encoding for
+ each implementation distinguishable NaN value.
+ ...
+includes: [nans.js, testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+function body(FloatArray) {
+ var first = new FloatArray(distinctNaNs);
+ var second = new FloatArray(distinctNaNs);
+ var firstBytes = new Uint8Array(first.buffer);
+ var secondBytes = new Uint8Array(second.buffer);
+
+ assert(compareArray(firstBytes, secondBytes));
+}
+
+testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation.js
new file mode 100644
index 000000000..959054911
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation.js
@@ -0,0 +1,53 @@
+// 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-object
+description: >
+ Verify conversion values on returned instance
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
+ ...
+
+ 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
+ isLittleEndian ] )
+
+ ...
+ 8. If type is "Float32", then
+ ...
+ 9. Else, if type is "Float64", then
+ ...
+ 10. Else,
+ ...
+ b. Let convOp be the abstract operation named in the Conversion Operation
+ column in Table 50 for Element Type type.
+ c. Let intValue be convOp(value).
+ d. If intValue ≥ 0, then
+ ...
+ e. Else,
+ ...
+includes: [byteConversionValues.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testTypedArrayConversions(byteConversionValues, function(TA, value, expected) {
+ var sample = new TA([value]);
+
+ assert.sameValue(sample[0], expected, value + " converts to " + expected);
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-custom-proto-access-throws.js
new file mode 100644
index 000000000..f5ced4ea4
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-custom-proto-access-throws.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-object
+description: >
+ Return abrupt completion getting newTarget's prototype
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ ...
+
+ 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 3. Let proto be ? Get(constructor, "prototype").
+ ...
+includes: [testTypedArray.js]
+features: [Reflect, TypedArray]
+---*/
+
+var newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+var o = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ Reflect.construct(TA, [o], newTarget);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterating-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterating-throws.js
new file mode 100644
index 000000000..41fc55509
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterating-throws.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-object
+description: >
+ Return abrupt from iterating object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var obj = (function *() {
+ yield 0;
+ throw new Test262Error();
+ })();
+
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-not-callable-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-not-callable-throws.js
new file mode 100644
index 000000000..ad6db0877
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-not-callable-throws.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-object
+description: >
+ Return abrupt when object @@iterator is not callable
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var obj = function () {};
+
+testWithTypedArrayConstructors(function(TA) {
+ obj[Symbol.iterator] = {};
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+
+ obj[Symbol.iterator] = true;
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+
+ obj[Symbol.iterator] = 42;
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-throws.js
new file mode 100644
index 000000000..571ad77ad
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-throws.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-object
+description: >
+ Return abrupt from getting object @@iterator
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var obj = function () {};
+
+Object.defineProperty(obj, Symbol.iterator, {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-excessive-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-excessive-throws.js
new file mode 100644
index 000000000..f8279f50a
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-excessive-throws.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-object
+description: >
+ Return abrupt from allocating array buffer with excessive length
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 6. Perform ? AllocateTypedArrayBuffer(O, len).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ length: Math.pow(2, 53)
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-is-symbol-throws.js
new file mode 100644
index 000000000..b452dea03
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-is-symbol-throws.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-object
+description: >
+ Return abrupt from length property as a Symbol on the object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 5. Let len be ? ToLength(? Get(arrayLike, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var obj = {
+ length: Symbol("1")
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-throws.js
new file mode 100644
index 000000000..08f8cd130
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-throws.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-object
+description: >
+ Return abrupt from getting length property on the object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 5. Let len be ? ToLength(? Get(arrayLike, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-new-instance-extensibility.js
new file mode 100644
index 000000000..86a2ac837
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-new-instance-extensibility.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-object
+description: >
+ The new typedArray instance from an object argument is extensible
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
+ "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ ...
+ 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 11. Set the [[Extensible]] internal slot of A to true.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ "0": 0,
+ "1": 1,
+ "2": 2,
+ length: 3
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(obj);
+
+ assert(Object.isExtensible(sample));
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-proto-from-ctor-realm.js
new file mode 100644
index 000000000..a92ceee00
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-proto-from-ctor-realm.js
@@ -0,0 +1,37 @@
+// 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-object
+description: Default [[Prototype]] value derived from realm of the newTarget
+info: |
+ [...]
+ 4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
+ "%TypedArrayPrototype%").
+ [...]
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ [...]
+
+ 9.1.14 GetPrototypeFromConstructor
+
+ [...]
+ 3. Let proto be ? Get(constructor, "prototype").
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+ b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
+ 5. Return proto.
+includes: [testTypedArray.js]
+features: [cross-realm, Reflect, TypedArray]
+---*/
+
+var other = $262.createRealm().global;
+var C = new other.Function();
+C.prototype = null;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [{}], C);
+
+ assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-returns.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-returns.js
new file mode 100644
index 000000000..57eec9720
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-returns.js
@@ -0,0 +1,45 @@
+// 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-object
+description: >
+ Return typedArray from object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var obj = {
+ "0": null,
+ "2": 42,
+ "3": "7",
+ "4": NaN,
+ "5": Symbol("1"),
+ length: 5
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(obj);
+ assert.sameValue(typedArray.length, 5);
+ assert.sameValue(typedArray[0], 0);
+ assert.sameValue(typedArray[2], 42);
+ assert.sameValue(typedArray[3], 7);
+ assert.sameValue(typedArray[5], undefined);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+
+ if (TA === Float32Array || TA === Float64Array) {
+ assert.sameValue(typedArray[1], NaN);
+ assert.sameValue(typedArray[4], NaN);
+ } else {
+ assert.sameValue(typedArray[1], 0);
+ assert.sameValue(typedArray[4], 0);
+ }
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-from-property.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-from-property.js
new file mode 100644
index 000000000..f9d384b5c
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-from-property.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-object
+description: >
+ Return abrupt from getting object property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ length: 4
+};
+
+Object.defineProperty(obj, "2", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js
new file mode 100644
index 000000000..215bf75fc
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js
@@ -0,0 +1,77 @@
+// 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-object
+description: >
+ Throw TypeError from @@toPrimitive returning an Object when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.toPrimitive, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var toPrimitive = 0;
+ var valueOf = 0;
+
+ sample[Symbol.toPrimitive] = function() {
+ toPrimitive++;
+ return {};
+ };
+
+ sample.valueOf = function() {
+ valueOf++;
+ };
+
+ assert.throws(TypeError, function() {
+ new TA([8, sample]);
+ }, "abrupt completion from sample @@toPrimitive");
+
+ assert.sameValue(toPrimitive, 1, "toPrimitive was called once");
+ assert.sameValue(valueOf, 0, "sample.valueOf is not called");
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive.js
new file mode 100644
index 000000000..7a7170b6f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive.js
@@ -0,0 +1,75 @@
+// 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-object
+description: >
+ Return abrupt from @@toPrimitive when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.toPrimitive, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var toPrimitive = 0;
+ var valueOf = 0;
+
+ sample[Symbol.toPrimitive] = function() {
+ toPrimitive++;
+ throw new Test262Error();
+ };
+
+ sample.valueOf = function() {
+ valueOf++;
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([8, sample]);
+ }, "abrupt completion from sample @@toPrimitive");
+
+ assert.sameValue(toPrimitive, 1, "toPrimitive was called once");
+ assert.sameValue(valueOf, 0, "it does not call sample.valueOf");
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-tostring.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-tostring.js
new file mode 100644
index 000000000..482e11595
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-tostring.js
@@ -0,0 +1,88 @@
+// 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-object
+description: >
+ Return abrupt from toString() when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+ var toString = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ return {};
+ };
+
+ sample.toString = function() {
+ toString++;
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([8, sample]);
+ }, "abrupt completion from ToNumber(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+ assert.sameValue(toString, 1, "toString called once");
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js
new file mode 100644
index 000000000..767dd2182
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js
@@ -0,0 +1,89 @@
+// 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-object
+description: >
+ Throw TypeError from OrdinaryToPrimitive when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ii. If Type(result) is not Object, return result.
+ 6. Throw a TypeError exception.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+ var toString = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ return {};
+ };
+
+ sample.toString = function() {
+ toString++;
+ return {};
+ };
+
+ assert.throws(TypeError, function() {
+ new TA([8, sample]);
+ }, "abrupt completion from ToNumber(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+ assert.sameValue(toString, 1, "toString called once");
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof.js
new file mode 100644
index 000000000..f9baf7758
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof.js
@@ -0,0 +1,82 @@
+// 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-object
+description: >
+ Return abrupt from valueOf() when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ii. If Type(result) is not Object, return result.
+ 6. Throw a TypeError exception.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([8, sample]);
+ }, "abrupt completion from ToNumber(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-property.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-property.js
new file mode 100644
index 000000000..93f85dc98
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-property.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-object
+description: >
+ Return abrupt from setting property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ "2": {
+ valueOf() {
+ throw new Test262Error();
+ }
+ },
+ length: 4
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-symbol-property.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-symbol-property.js
new file mode 100644
index 000000000..42b4a54b8
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-symbol-property.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-object
+description: >
+ Return abrupt from setting property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var obj = {
+ "2": Symbol("1"),
+ length: 4
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-undefined-newtarget-throws.js
new file mode 100644
index 000000000..36f68493a
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-undefined-newtarget-throws.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-object
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 2. If NewTarget is undefined, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ TA({});
+ });
+
+ assert.throws(TypeError, function() {
+ TA([]);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-custom-proto-if-object.js
new file mode 100644
index 000000000..bb5754a9c
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-custom-proto-if-object.js
@@ -0,0 +1,47 @@
+// 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-object
+description: >
+ Use prototype from new target if it's an Object
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 10. Set the [[Prototype]] internal slot of A to prototype.
+ ...
+ 12. Return A.
+includes: [testTypedArray.js]
+features: [Reflect, TypedArray]
+---*/
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [], newTarget);
+
+ assert.sameValue(ta.constructor, Object);
+ assert.sameValue(Object.getPrototypeOf(ta), proto);
+});
diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js
new file mode 100644
index 000000000..6aba187c2
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js
@@ -0,0 +1,47 @@
+// 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-object
+description: >
+ Use prototype from %TypedArray% if newTarget's prototype is not an Object
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 10. Set the [[Prototype]] internal slot of A to prototype.
+ ...
+ 12. Return A.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+function newTarget() {}
+newTarget.prototype = null;
+var o = [];
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [o], newTarget);
+
+ assert.sameValue(ta.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta), TA.prototype);
+});