Skip to content

Commit cba890e

Browse files
DevSDKMs2ger
authored andcommitted
add throw-type-error-before-custom-proto-access.js
1 parent 443f0d2 commit cba890e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2025 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
/*---
4+
esid: sec-typedarray
5+
description: >
6+
The newTarget getter must not be evaluated if argument processing throws an error before AllocateTypedArray is reached
7+
info: |
8+
23.2.5.1 TypedArray ( ...args )
9+
...
10+
5. If numberOfArgs = 0, then
11+
a. Return ? AllocateTypedArray(constructorName, NewTarget, proto, 0).
12+
6. Else,
13+
a. Let firstArgument be args[0].
14+
b. If firstArgument is an Object, then
15+
...
16+
c. Else,
17+
i. Assert: firstArgument is not an Object.
18+
ii. Let elementLength be ? ToIndex(firstArgument).
19+
iii. Return ? AllocateTypedArray(constructorName, NewTarget, proto, elementLength).
20+
21+
7.1.22 ToIndex ( value )
22+
1. Let integer be ? ToIntegerOrInfinity(value).
23+
...
24+
25+
7.1.5 ToIntegerOrInfinity ( argument )
26+
1. Let number be ? ToNumber(argument).
27+
...
28+
29+
7.1.4 ToNumber ( argument )
30+
1. If argument is a Number, return argument.
31+
2. If argument is either a Symbol or a BigInt, throw a TypeError exception.
32+
...
33+
34+
includes: [testTypedArray.js]
35+
features: [Reflect, TypedArray]
36+
---*/
37+
38+
var newTarget = function () {}.bind(null);
39+
Object.defineProperty(newTarget, "prototype", {
40+
get() {
41+
throw new Test262Error();
42+
},
43+
});
44+
45+
testWithTypedArrayConstructors(function (TA) {
46+
assert.throws(TypeError, function () {
47+
Reflect.construct(TA, [Symbol()], newTarget);
48+
});
49+
});

0 commit comments

Comments
 (0)