-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
729 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (C) 2019 Leo Balter. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-finalization-group-target | ||
description: Instances of FinalizationGroup are extensible | ||
info: | | ||
FinalizationGroup ( cleanupCallback ) | ||
... | ||
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »). | ||
... | ||
9. Return finalizationGroup. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
ObjectCreate ( proto [ , internalSlotsList ] ) | ||
4. Set obj.[[Prototype]] to proto. | ||
5. Set obj.[[Extensible]] to true. | ||
6. Return obj. | ||
features: [FinalizationGroup, Reflect] | ||
---*/ | ||
|
||
var fg = new FinalizationGroup(function() {}); | ||
assert.sameValue(Object.isExtensible(fg), true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
test/built-ins/FinalizationGroup/newtarget-prototype-is-not-object.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (C) 2019 Leo Balter. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-finalization-group-target | ||
description: > | ||
[[Prototype]] defaults to %FinalizationGroupPrototype% if NewTarget.prototype is not an object. | ||
info: | | ||
FinalizationGroup ( cleanupCallback ) | ||
... | ||
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »). | ||
... | ||
9. Return finalizationGroup. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) | ||
3. Let proto be ? Get(constructor, 'prototype'). | ||
4. If Type(proto) is not Object, then | ||
a. Let realm be ? GetFunctionRealm(constructor). | ||
b. Set proto to realm's intrinsic object named intrinsicDefaultProto. | ||
5. Return proto. | ||
features: [FinalizationGroup, Reflect.construct, Symbol] | ||
---*/ | ||
|
||
var fg; | ||
function newTarget() {} | ||
function fn() {} | ||
|
||
newTarget.prototype = undefined; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is undefined'); | ||
|
||
newTarget.prototype = null; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is null'); | ||
|
||
newTarget.prototype = true; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is a Boolean'); | ||
|
||
newTarget.prototype = ''; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is a String'); | ||
|
||
newTarget.prototype = Symbol(); | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is a Symbol'); | ||
|
||
newTarget.prototype = 1; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is a Number'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2019 Leo Balter. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-finalization-group-target | ||
description: Default [[Prototype]] value derived from realm of the newTarget | ||
info: | | ||
FinalizationGroup ( cleanupCallback ) | ||
... | ||
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »). | ||
... | ||
9. Return finalizationGroup. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) | ||
3. Let proto be ? Get(constructor, 'prototype'). | ||
4. If Type(proto) is not Object, then | ||
a. Let realm be ? GetFunctionRealm(constructor). | ||
b. Set proto to realm's intrinsic object named intrinsicDefaultProto. | ||
5. Return proto. | ||
features: [FinalizationGroup, cross-realm, Reflect] | ||
---*/ | ||
|
||
var other = $262.createRealm().global; | ||
var newTarget = new other.Function(); | ||
function fn() {} | ||
var fg; | ||
|
||
newTarget.prototype = undefined; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is undefined'); | ||
|
||
newTarget.prototype = null; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is null'); | ||
|
||
newTarget.prototype = true; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Boolean'); | ||
|
||
newTarget.prototype = ''; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a String'); | ||
|
||
newTarget.prototype = Symbol(); | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Symbol'); | ||
|
||
newTarget.prototype = 1; | ||
fg = Reflect.construct(FinalizationGroup, [fn], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Number'); | ||
|
41 changes: 41 additions & 0 deletions
41
test/built-ins/FinalizationGroup/prototype-from-newtarget-abrupt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (C) 2019 Leo Balter. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-finalization-group-target | ||
description: > | ||
Return abrupt from getting the NewTarget prototype | ||
info: | | ||
FinalizationGroup ( cleanupCallback ) | ||
... | ||
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »). | ||
... | ||
9. Return finalizationGroup. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) | ||
3. Let proto be ? Get(constructor, 'prototype'). | ||
features: [FinalizationGroup, Reflect.construct] | ||
---*/ | ||
|
||
var calls = 0; | ||
var newTarget = function() {}.bind(null); | ||
Object.defineProperty(newTarget, 'prototype', { | ||
get: function() { | ||
calls += 1; | ||
throw new Test262Error(); | ||
} | ||
}); | ||
|
||
assert.throws(Test262Error, function() { | ||
Reflect.construct(FinalizationGroup, [{}], newTarget); | ||
}); | ||
|
||
assert.sameValue(calls, 1); |
44 changes: 44 additions & 0 deletions
44
test/built-ins/FinalizationGroup/prototype-from-newtarget-custom.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) 2019 Leo Balter. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-finalization-group-target | ||
description: > | ||
The [[Prototype]] internal slot is computed from NewTarget. | ||
info: | | ||
FinalizationGroup ( cleanupCallback ) | ||
... | ||
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »). | ||
... | ||
9. Return finalizationGroup. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) | ||
3. Let proto be ? Get(constructor, 'prototype'). | ||
4. If Type(proto) is not Object, then | ||
a. Let realm be ? GetFunctionRealm(constructor). | ||
b. Set proto to realm's intrinsic object named intrinsicDefaultProto. | ||
5. Return proto. | ||
features: [FinalizationGroup, Reflect.construct] | ||
---*/ | ||
|
||
var fg; | ||
|
||
fg = Reflect.construct(FinalizationGroup, [function() {}], Object); | ||
assert.sameValue(Object.getPrototypeOf(fg), Object.prototype, 'NewTarget is built-in Object constructor'); | ||
|
||
var newTarget = function() {}.bind(null); | ||
Object.defineProperty(newTarget, 'prototype', { | ||
get: function() { | ||
return Array.prototype; | ||
} | ||
}); | ||
fg = Reflect.construct(FinalizationGroup, [function() {}], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(fg), Array.prototype, 'NewTarget is BoundFunction with accessor'); |
33 changes: 33 additions & 0 deletions
33
test/built-ins/FinalizationGroup/prototype-from-newtarget.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (C) 2019 Leo Balter. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-finalization-group-target | ||
description: > | ||
The [[Prototype]] internal slot is computed from NewTarget. | ||
info: | | ||
FinalizationGroup ( cleanupCallback ) | ||
... | ||
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »). | ||
... | ||
9. Return finalizationGroup. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) | ||
3. Let proto be ? Get(constructor, 'prototype'). | ||
4. If Type(proto) is not Object, then | ||
a. Let realm be ? GetFunctionRealm(constructor). | ||
b. Set proto to realm's intrinsic object named intrinsicDefaultProto. | ||
5. Return proto. | ||
features: [FinalizationGroup] | ||
---*/ | ||
|
||
var fg = new FinalizationGroup(function() {}); | ||
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.