Debian Codegraph @

js/src/tests/test262/built-ins/NativeErrors/AggregateError/newtarget-proto-custom.js

raw
1 // Copyright (C) 2019 Leo Balter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-aggregate-error
6 description: >
7 Use a custom NewTarget prototype
8 info: |
9 AggregateError ( errors, message )
10
11 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
12 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
13 ...
14 6. Return O.
15
16 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
17
18 ...
19 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
20 3. Return ObjectCreate(proto, internalSlotsList).
21
22 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
23
24 ...
25 3. Let proto be ? Get(constructor, "prototype").
26 4. If Type(proto) is not Object, then
27 a. Let realm be ? GetFunctionRealm(constructor).
28 b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
29 Return proto.
30 features: [AggregateError, Reflect.construct]
31 ---*/
32
33 var custom = { x: 42 };
34 var newt = new Proxy(function() {}, {
35 get(t, p) {
36 if (p === 'prototype') {
37 return custom;
38 }
39
40 return t[p];
41 }
42 });
43
44 var obj = Reflect.construct(AggregateError, [[]], newt);
45
46 assert.sameValue(Object.getPrototypeOf(obj), custom);
47 assert.sameValue(obj.x, 42);
48
49 reportCompare(0, 0);