diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/detached-when-species-retrieved-different-type.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/detached-when-species-retrieved-different-type.js deleted file mode 100644 index 4b914e6d2ef..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/detached-when-species-retrieved-different-type.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2017 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - When a TypedArray is created from another TypedArray with a different element-type - and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still - executed. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 16. If IsSharedArrayBuffer(srcData) is false, then - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - 18. If SameValue(elementType, srcType) is true, then - ... - 19. Else, - a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", - « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). - ... -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] -features: [BigInt, TypedArray, Symbol.species] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var speciesCallCount = 0; - var bufferConstructor = Object.defineProperty({}, Symbol.species, { - get: function() { - speciesCallCount += 1; - $DETACHBUFFER(ta.buffer); - return speciesConstructor; - } - }); - - var prototypeCallCount = 0; - var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { - get: function() { - prototypeCallCount += 1; - return null; - } - }); - - var ta = new TA(0); - ta.buffer.constructor = bufferConstructor; - - assert.throws(TypeError, function() { - var targetType = TA !== BigInt64Array ? BigInt64Array : BigUint64Array; - new targetType(ta); - }, "TypeError thrown for detached source buffer"); - - assert.sameValue(speciesCallCount, 1, "@@species getter called once"); - assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/detached-when-species-retrieved-same-type.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/detached-when-species-retrieved-same-type.js deleted file mode 100644 index c4f45c49c7c..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/detached-when-species-retrieved-same-type.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2017 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - When a TypedArray is created from another TypedArray with the same element-type - and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still - executed. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 16. If IsSharedArrayBuffer(srcData) is false, then - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - 18. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, byteLength, bufferConstructor). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset, srcLength, cloneConstructor ) - - ... - 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). - 4. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", - « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). - ... -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] -features: [BigInt, TypedArray, Symbol.species] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var speciesCallCount = 0; - var bufferConstructor = Object.defineProperty({}, Symbol.species, { - get: function() { - speciesCallCount += 1; - $DETACHBUFFER(ta.buffer); - return speciesConstructor; - } - }); - - var prototypeCallCount = 0; - var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { - get: function() { - prototypeCallCount += 1; - return null; - } - }); - - var ta = new TA(0); - ta.buffer.constructor = bufferConstructor; - - assert.throws(TypeError, function() { - new TA(ta); - }, "TypeError thrown for detached source buffer"); - - assert.sameValue(speciesCallCount, 1, "@@species getter called once"); - assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-access-throws.js deleted file mode 100644 index 3882f1c78e8..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-access-throws.js +++ /dev/null @@ -1,41 +0,0 @@ -// 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-typedarray -description: > - Return abrupt completion from getting typedArray argument's buffer.constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var OtherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array; - var sample = new OtherCtor(); - - Object.defineProperty(sample.buffer, "constructor", { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js deleted file mode 100644 index 5a5d7ee0ab7..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js +++ /dev/null @@ -1,58 +0,0 @@ -// 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-typedarray -description: > - Derive the ArrayBuffer prototype from the realm of the species constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 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. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, cross-realm, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = C; - - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype - ); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species.js deleted file mode 100644 index 1ff1e5db533..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species.js +++ /dev/null @@ -1,52 +0,0 @@ -// 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-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var ctor = {}; - var called = 0; - var custom = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() { - called++; - }; - - ctor[Symbol.species].prototype = custom; - - var typedArray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js deleted file mode 100644 index 44b76c2b95e..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js +++ /dev/null @@ -1,61 +0,0 @@ -// 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-typedarray -description: > - Return abrupt completion from typedArray argument's buffer.constructor's value -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... - 4. If Type(C) is not Object, throw a TypeError exception. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - - sample.buffer.constructor = 1; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = true; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = ""; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = null; - assert.throws(TypeError, function() { - new TA(sample); - }); - - var s = Symbol("1"); - sample.buffer.constructor = s; - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js deleted file mode 100644 index 8b3933eedb5..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js +++ /dev/null @@ -1,45 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var ctor = {}; - - sample.buffer.constructor = ctor; - Object.defineProperty(ctor, Symbol.species, { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js deleted file mode 100644 index 09a8068e9f2..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js +++ /dev/null @@ -1,47 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - 8. Throw a TypeError exception. -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -var ctor = function() { - throw new Test262Error(); -}; -var m = { m() {} }.m; -ctor[Symbol.species] = m; - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - - sample.buffer.constructor = ctor; - - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js deleted file mode 100644 index 705b8a7319c..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - ... - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, - "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var ctor = {}; - var called = 0; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() {called++;}.bind(null); - Object.defineProperty(ctor[Symbol.species], "prototype", { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-access-throws.js deleted file mode 100644 index 51fa9a8358f..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-access-throws.js +++ /dev/null @@ -1,46 +0,0 @@ -// 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-typedarray -description: > - Return abrupt completion from getting typedArray argument's buffer.constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js deleted file mode 100644 index 90de9642805..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js +++ /dev/null @@ -1,68 +0,0 @@ -// 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-typedarray -description: > - Derive the ArrayBuffer prototype from the realm of the species constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... - - 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. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, cross-realm, Symbol.species, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = C; - - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype - ); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom.js deleted file mode 100644 index 743b03e3f4b..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom.js +++ /dev/null @@ -1,60 +0,0 @@ -// 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-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - var called = 0; - var custom = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() { - called++; - }; - - ctor[Symbol.species].prototype = custom; - - var typedArray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js deleted file mode 100644 index 32cbc01bc3f..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js +++ /dev/null @@ -1,49 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - 8. Throw a TypeError exception. -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - var m = { m() {} }; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = m; - - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js deleted file mode 100644 index 042d4213db8..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js +++ /dev/null @@ -1,62 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - ... - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, - "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function(){}.bind(null); - Object.defineProperty(ctor[Symbol.species], "prototype", { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-throws.js deleted file mode 100644 index 0aa7517b802..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-throws.js +++ /dev/null @@ -1,49 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - Object.defineProperty(ctor, Symbol.species, { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js b/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js deleted file mode 100644 index a3ca9a041b3..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js +++ /dev/null @@ -1,65 +0,0 @@ -// 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-typedarray -description: > - Return abrupt completion from typedArray argument's buffer.constructor's value -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... - 4. If Type(C) is not Object, throw a TypeError exception. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - - sample.buffer.constructor = 1; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = true; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = ''; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = null; - assert.throws(TypeError, function() { - new TA(sample); - }); - - var s = Symbol('1'); - sample.buffer.constructor = s; - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/no-species.js b/test/built-ins/TypedArrayConstructors/ctors/no-species.js new file mode 100644 index 00000000000..9fdced7e986 --- /dev/null +++ b/test/built-ins/TypedArrayConstructors/ctors/no-species.js @@ -0,0 +1,30 @@ +// Copyright (C) 2022 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Creating TypedArray from other TypedArrays doesn't look up Symbol.species. +features: [Symbol.species] +---*/ + +let throwOnGrossBufferConstruction = false; + +class GrossBuffer extends ArrayBuffer { + constructor() { + super(...arguments); + if (throwOnGrossBufferConstruction) { + throw new Test262Error("unreachable"); + } + } + static get [Symbol.species]() { + throw new Test262Error("unreachable"); + } +} + +let grossBuf = new GrossBuffer(1024); +throwOnGrossBufferConstruction = true; +let grossTA = new Uint8Array(grossBuf); +let mysteryTA = new Int8Array(grossTA); + +assert.sameValue(mysteryTA.buffer.__proto__, ArrayBuffer.prototype); +assert.sameValue(mysteryTA.buffer.constructor, ArrayBuffer); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/detached-when-species-retrieved-different-type.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/detached-when-species-retrieved-different-type.js deleted file mode 100644 index 8ee2fba54bc..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/detached-when-species-retrieved-different-type.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2017 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - When a TypedArray is created from another TypedArray with a different element-type - and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still - executed. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 16. If IsSharedArrayBuffer(srcData) is false, then - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - 18. If SameValue(elementType, srcType) is true, then - ... - 19. Else, - a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", - « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). - ... -includes: [testTypedArray.js, detachArrayBuffer.js] -features: [TypedArray, Symbol.species] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var speciesCallCount = 0; - var bufferConstructor = Object.defineProperty({}, Symbol.species, { - get: function() { - speciesCallCount += 1; - $DETACHBUFFER(ta.buffer); - return speciesConstructor; - } - }); - - var prototypeCallCount = 0; - var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { - get: function() { - prototypeCallCount += 1; - return null; - } - }); - - var ta = new TA(0); - ta.buffer.constructor = bufferConstructor; - - assert.throws(TypeError, function() { - var targetType = TA !== Int32Array ? Int32Array : Uint32Array; - new targetType(ta); - }, "TypeError thrown for detached source buffer"); - - assert.sameValue(speciesCallCount, 1, "@@species getter called once"); - assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/detached-when-species-retrieved-same-type.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/detached-when-species-retrieved-same-type.js deleted file mode 100644 index 978f42af64b..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/detached-when-species-retrieved-same-type.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2017 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - When a TypedArray is created from another TypedArray with the same element-type - and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still - executed. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 16. If IsSharedArrayBuffer(srcData) is false, then - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - 18. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, byteLength, bufferConstructor). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset, srcLength, cloneConstructor ) - - ... - 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). - 4. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", - « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). - ... -includes: [testTypedArray.js, detachArrayBuffer.js] -features: [TypedArray, Symbol.species] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var speciesCallCount = 0; - var bufferConstructor = Object.defineProperty({}, Symbol.species, { - get: function() { - speciesCallCount += 1; - $DETACHBUFFER(ta.buffer); - return speciesConstructor; - } - }); - - var prototypeCallCount = 0; - var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { - get: function() { - prototypeCallCount += 1; - return null; - } - }); - - var ta = new TA(0); - ta.buffer.constructor = bufferConstructor; - - assert.throws(TypeError, function() { - new TA(ta); - }, "TypeError thrown for detached source buffer"); - - assert.sameValue(speciesCallCount, 1, "@@species getter called once"); - assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-access-throws.js deleted file mode 100644 index b8976d696de..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-access-throws.js +++ /dev/null @@ -1,41 +0,0 @@ -// 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-typedarray -description: > - Return abrupt completion from getting typedArray argument's buffer.constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var OtherCtor = TA === Int8Array ? Int16Array : Int8Array; - var sample = new OtherCtor(); - - Object.defineProperty(sample.buffer, "constructor", { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js deleted file mode 100644 index 03860d1a7be..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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-typedarray -description: > - Derive the ArrayBuffer prototype from the realm of the species constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 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. - ... -includes: [testTypedArray.js] -features: [cross-realm, Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = C; - - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype - ); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species.js deleted file mode 100644 index a510d7806da..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species.js +++ /dev/null @@ -1,52 +0,0 @@ -// 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-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - var called = 0; - var custom = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() { - called++; - }; - - ctor[Symbol.species].prototype = custom; - - var typedArray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js deleted file mode 100644 index cfb79f1a948..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js +++ /dev/null @@ -1,61 +0,0 @@ -// 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-typedarray -description: > - Return abrupt completion from typedArray argument's buffer.constructor's value -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... - 4. If Type(C) is not Object, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - - sample.buffer.constructor = 1; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = true; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = ""; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = null; - assert.throws(TypeError, function() { - new TA(sample); - }); - - var s = Symbol("1"); - sample.buffer.constructor = s; - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js deleted file mode 100644 index 4b0b19aca73..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js +++ /dev/null @@ -1,45 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - - sample.buffer.constructor = ctor; - Object.defineProperty(ctor, Symbol.species, { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js deleted file mode 100644 index c485cae138f..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js +++ /dev/null @@ -1,47 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - 8. Throw a TypeError exception. -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -var ctor = function() { - throw new Test262Error(); -}; -var m = { m() {} }.m; -ctor[Symbol.species] = m; - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - - sample.buffer.constructor = ctor; - - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-null.js deleted file mode 100644 index 96ba9009d66..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-null.js +++ /dev/null @@ -1,44 +0,0 @@ -// 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-typedarray -description: > - Use default ArrayBuffer constructor on null buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var OtherCtor = TA === Int8Array ? Int16Array : Int8Array; - var sample = new OtherCtor(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = null; - var typedArray = new TA(sample); - - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is null" - ); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js deleted file mode 100644 index 135634646b4..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - ... - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, - "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - var called = 0; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() {called++;}.bind(null); - Object.defineProperty(ctor[Symbol.species], "prototype", { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js deleted file mode 100644 index 32e78a37dcd..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js +++ /dev/null @@ -1,43 +0,0 @@ -// 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-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var OtherCtor = TA === Int8Array ? Int16Array : Int8Array; - var sample = new OtherCtor(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = undefined; - var a = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(a.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is undefined" - ); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/out-of-bounds-when-species-retrieved-different-type.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/out-of-bounds-when-species-retrieved-different-type.js deleted file mode 100644 index 0aba12fc80f..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/out-of-bounds-when-species-retrieved-different-type.js +++ /dev/null @@ -1,89 +0,0 @@ -// 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-typedarray -description: > - Error when a TypedArray is created from another TypedArray with a different - element-type and SpeciesConstructor causes the "source" array to go - out-of-bounds. -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, Symbol.species, resizable-arraybuffer] ----*/ - -// If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` -// has not been implemented. The following assertion prevents this test from -// passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); - -testWithTypedArrayConstructors(function(TA) { - var BPE = TA.BYTES_PER_ELEMENT; - var TargetCtor = TA !== Int32Array ? Int32Array : Uint32Array; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); - var speciesConstructor = Object.defineProperty(function(){}.bind(), 'prototype', { - get: function() { - return null; - } - }); - var onGetSpecies; - ab.constructor = Object.defineProperty({}, Symbol.species, { - get: function() { - onGetSpecies(); - return speciesConstructor; - } - }); - var source = new TA(ab, BPE); - var expected = [10, 20, 30]; - - source[0] = 10; - source[1] = 20; - source[2] = 30; - - onGetSpecies = function() { - try { - ab.resize(BPE * 5); - expected = [10, 20, 30, 0]; - } catch (_) {} - }; - - assert(compareArray(new TargetCtor(source), expected), 'following grow'); - - onGetSpecies = function() { - try { - ab.resize(BPE * 3); - expected = [10, 20]; - } catch (_) {} - }; - - assert(compareArray(new TargetCtor(source), expected), 'following shrink (within bounds)'); - - onGetSpecies = function() { - try { - ab.resize(BPE); - expected = []; - } catch (_) {} - }; - - assert(compareArray(new TargetCtor(source), expected), 'following shrink (on boundary)'); - - // `assert.throws` cannot be used in this case because the expected error - // is derived only after the constructor is invoked. - var expectedError; - var actualError; - onGetSpecies = function() { - try { - ab.resize(0); - expectedError = TypeError; - } catch (_) { - expectedError = Test262Error; - } - }; - try { - new TargetCtor(source); - throw new Test262Error('the operation completed successfully'); - } catch (caught) { - actualError = caught; - } - - assert.sameValue(actualError.constructor, expectedError); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/out-of-bounds-when-species-retrieved-same-type.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/out-of-bounds-when-species-retrieved-same-type.js deleted file mode 100644 index c633ba06962..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/out-of-bounds-when-species-retrieved-same-type.js +++ /dev/null @@ -1,89 +0,0 @@ -// 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-typedarray -description: > - Error when a TypedArray is created from another TypedArray with the same - element-type and SpeciesConstructor causes the "source" array to go - out-of-bounds. -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, Symbol.species, resizable-arraybuffer] ----*/ - -// If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` -// has not been implemented. The following assertion prevents this test from -// passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); - -testWithTypedArrayConstructors(function(TA) { - var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); - var speciesConstructor = Object.defineProperty(function(){}.bind(), 'prototype', { - get: function() { - return null; - } - }); - var onGetSpecies; - ab.constructor = Object.defineProperty({}, Symbol.species, { - get: function() { - onGetSpecies(); - return speciesConstructor; - } - }); - var source = new TA(ab, BPE); - var expected = [10, 20, 30]; - - source[0] = 10; - source[1] = 20; - source[2] = 30; - - onGetSpecies = function() { - try { - ab.resize(BPE * 5); - expected = [10, 20, 30, 0]; - } catch (_) {} - }; - - assert.sameValue((new TA(source)).join(','), expected.join(',')); - assert(compareArray(new TA(source), expected), 'following grow'); - - onGetSpecies = function() { - try { - ab.resize(BPE * 3); - expected = [10, 20]; - } catch (_) {} - }; - - assert(compareArray(new TA(source), expected), 'following shrink (within bounds)'); - - onGetSpecies = function() { - try { - ab.resize(BPE); - expected = []; - } catch (_) {} - }; - - assert(compareArray(new TA(source), expected), 'following shrink (on boundary)'); - - // `assert.throws` cannot be used in this case because the expected error - // is derived only after the constructor is invoked. - var expectedError; - var actualError; - onGetSpecies = function() { - try { - ab.resize(0); - expectedError = TypeError; - } catch (_) { - expectedError = Test262Error; - } - }; - try { - new TA(source); - throw new Test262Error('the operation completed successfully'); - } catch (caught) { - actualError = caught; - } - - assert.sameValue(actualError.constructor, expectedError); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-access-throws.js deleted file mode 100644 index f8e75d20916..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-access-throws.js +++ /dev/null @@ -1,46 +0,0 @@ -// 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-typedarray -description: > - Return abrupt completion from getting typedArray argument's buffer.constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js deleted file mode 100644 index 43743b956e7..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js +++ /dev/null @@ -1,68 +0,0 @@ -// 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-typedarray -description: > - Derive the ArrayBuffer prototype from the realm of the species constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... - - 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. - ... -includes: [testTypedArray.js] -features: [cross-realm, Symbol.species, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = C; - - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype - ); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom.js deleted file mode 100644 index 7ed3aca0da1..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom.js +++ /dev/null @@ -1,60 +0,0 @@ -// 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-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - var called = 0; - var custom = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() { - called++; - }; - - ctor[Symbol.species].prototype = custom; - - var typedArray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js deleted file mode 100644 index 2072aa96dd1..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js +++ /dev/null @@ -1,49 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - 8. Throw a TypeError exception. -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - var m = { m() {} }; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = m; - - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js deleted file mode 100644 index b171826cfb1..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js +++ /dev/null @@ -1,62 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - 6. If S is either undefined or null, return defaultConstructor. - 7. If IsConstructor(S) is true, return S. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - ... - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, - "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function(){}.bind(null); - Object.defineProperty(ctor[Symbol.species], "prototype", { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-throws.js deleted file mode 100644 index ec2aaf3c1f5..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-throws.js +++ /dev/null @@ -1,49 +0,0 @@ -// 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-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - Object.defineProperty(ctor, Symbol.species, { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js b/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js deleted file mode 100644 index ef97097495c..00000000000 --- a/test/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js +++ /dev/null @@ -1,65 +0,0 @@ -// 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-typedarray -description: > - Return abrupt completion from typedArray argument's buffer.constructor's value -info: | - 22.2.4.3 TypedArray ( typedArray ) - - 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 has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... - 4. If Type(C) is not Object, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - - sample.buffer.constructor = 1; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = true; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = ''; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = null; - assert.throws(TypeError, function() { - new TA(sample); - }); - - var s = Symbol('1'); - sample.buffer.constructor = s; - assert.throws(TypeError, function() { - new TA(sample); - }); -});