|
| 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-finalization-group-target |
| 6 | +description: Default [[Prototype]] value derived from realm of the newTarget |
| 7 | +info: | |
| 8 | + FinalizationGroup ( cleanupCallback ) |
| 9 | +
|
| 10 | + ... |
| 11 | + 3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »). |
| 12 | + ... |
| 13 | + 9. Return finalizationGroup. |
| 14 | +
|
| 15 | + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) |
| 16 | +
|
| 17 | + ... |
| 18 | + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). |
| 19 | + 3. Return ObjectCreate(proto, internalSlotsList). |
| 20 | +
|
| 21 | + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) |
| 22 | +
|
| 23 | + 3. Let proto be ? Get(constructor, 'prototype'). |
| 24 | + 4. If Type(proto) is not Object, then |
| 25 | + a. Let realm be ? GetFunctionRealm(constructor). |
| 26 | + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. |
| 27 | + 5. Return proto. |
| 28 | +features: [FinalizationGroup, cross-realm, Reflect] |
| 29 | +---*/ |
| 30 | + |
| 31 | +var other = $262.createRealm().global; |
| 32 | +var newTarget = new other.Function(); |
| 33 | +function fn() {} |
| 34 | +var fg; |
| 35 | + |
| 36 | +newTarget.prototype = undefined; |
| 37 | +fg = Reflect.construct(FinalizationGroup, [fn], newTarget); |
| 38 | +assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is undefined'); |
| 39 | + |
| 40 | +newTarget.prototype = null; |
| 41 | +fg = Reflect.construct(FinalizationGroup, [fn], newTarget); |
| 42 | +assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is null'); |
| 43 | + |
| 44 | +newTarget.prototype = true; |
| 45 | +fg = Reflect.construct(FinalizationGroup, [fn], newTarget); |
| 46 | +assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Boolean'); |
| 47 | + |
| 48 | +newTarget.prototype = ''; |
| 49 | +fg = Reflect.construct(FinalizationGroup, [fn], newTarget); |
| 50 | +assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a String'); |
| 51 | + |
| 52 | +newTarget.prototype = Symbol(); |
| 53 | +fg = Reflect.construct(FinalizationGroup, [fn], newTarget); |
| 54 | +assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Symbol'); |
| 55 | + |
| 56 | +newTarget.prototype = 1; |
| 57 | +fg = Reflect.construct(FinalizationGroup, [fn], newTarget); |
| 58 | +assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Number'); |
| 59 | + |
0 commit comments