mirror of https://github.com/tc39/test262.git
Improve GetFunctionRealm coverage (#2155)
* Fix Function.prototype.bind test * Simplify Proxy test * Info tweaks * Add Function.prototype.bind recursive test * Add Proxy recursive test
This commit is contained in:
parent
1951d335d6
commit
6f4c0d96f7
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-getfunctionrealm
|
||||
description: >
|
||||
The realm of a bound function exotic object is the realm of its target
|
||||
function. GetFunctionRealm is called recursively.
|
||||
info: |
|
||||
7.3.22 GetFunctionRealm ( obj )
|
||||
|
||||
[...]
|
||||
2. If obj has a [[Realm]] internal slot, then
|
||||
a. Return obj.[[Realm]].
|
||||
3. If obj is a Bound Function exotic object, then
|
||||
a. Let target be obj.[[BoundTargetFunction]].
|
||||
b. Return ? GetFunctionRealm(target).
|
||||
features: [cross-realm]
|
||||
---*/
|
||||
|
||||
var other = $262.createRealm().global;
|
||||
var C = new other.Function();
|
||||
C.prototype = null;
|
||||
var B = C.bind().bind();
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(new B()), other.Object.prototype);
|
|
@ -7,17 +7,20 @@ description: >
|
|||
The realm of a bound function exotic object is the realm of its target
|
||||
function
|
||||
info: |
|
||||
7.3.22 GetFunctionRealm ( obj )
|
||||
|
||||
[...]
|
||||
2. If obj has a [[Realm]] internal slot, then
|
||||
a, Return obj's [[Realm]] internal slot.
|
||||
a. Return obj.[[Realm]].
|
||||
3. If obj is a Bound Function exotic object, then
|
||||
a. Let target be obj's [[BoundTargetFunction]] internal slot.
|
||||
a. Let target be obj.[[BoundTargetFunction]].
|
||||
b. Return ? GetFunctionRealm(target).
|
||||
features: [cross-realm]
|
||||
---*/
|
||||
|
||||
var other = $262.createRealm().global;
|
||||
var C = new other.Function();
|
||||
var B = Function.prototype.bind.call(C);
|
||||
C.prototype = null;
|
||||
var B = C.bind();
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(new B()), C.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(new B()), other.Object.prototype);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-getfunctionrealm
|
||||
description: >
|
||||
The realm of a proxy exotic object is the realm of its target function.
|
||||
GetFunctionRealm is called recursively.
|
||||
info: |
|
||||
7.3.22 GetFunctionRealm ( obj )
|
||||
|
||||
[...]
|
||||
2. If obj has a [[Realm]] internal slot, then
|
||||
a. Return obj.[[Realm]].
|
||||
[...]
|
||||
4. If obj is a Proxy exotic object, then
|
||||
a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
|
||||
b. Let proxyTarget be obj.[[ProxyTarget]].
|
||||
c. Return ? GetFunctionRealm(proxyTarget).
|
||||
features: [cross-realm, Proxy]
|
||||
---*/
|
||||
|
||||
var other = $262.createRealm().global;
|
||||
var C = new other.Function();
|
||||
C.prototype = null;
|
||||
var P = new Proxy(new Proxy(C, {}), {});
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(new P()), other.Object.prototype);
|
|
@ -6,24 +6,22 @@ es6id: 7.3.22
|
|||
description: >
|
||||
The realm of a proxy exotic object is the realm of its target function
|
||||
info: |
|
||||
7.3.22 GetFunctionRealm ( obj )
|
||||
|
||||
[...]
|
||||
2. If obj has a [[Realm]] internal slot, then
|
||||
a, Return obj's [[Realm]] internal slot.
|
||||
3. If obj is a Bound Function exotic object, then
|
||||
[...]
|
||||
a. Return obj.[[Realm]].
|
||||
[...]
|
||||
4. If obj is a Proxy exotic object, then
|
||||
a. If the value of the [[ProxyHandler]] internal slot of obj is null,
|
||||
throw a TypeError exception.
|
||||
b. Let proxyTarget be the value of obj's [[ProxyTarget]] internal slot.
|
||||
a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
|
||||
b. Let proxyTarget be obj.[[ProxyTarget]].
|
||||
c. Return ? GetFunctionRealm(proxyTarget).
|
||||
features: [cross-realm, Proxy]
|
||||
---*/
|
||||
|
||||
var other = $262.createRealm().global;
|
||||
var C = new other.Function();
|
||||
// Ensure that the proxy does not report a `prototype` property
|
||||
var P = new Proxy(C, {
|
||||
get: function() {}
|
||||
});
|
||||
C.prototype = null;
|
||||
var P = new Proxy(C, {});
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(new P()), other.Object.prototype);
|
||||
|
|
Loading…
Reference in New Issue