Debian Codegraph @

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

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