mirror of
https://github.com/tc39/test262.git
synced 2025-07-29 17:04:31 +02:00
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
25
test/built-ins/Function/prototype/bind/get-fn-realm-recursive.js
vendored
Normal file
25
test/built-ins/Function/prototype/bind/get-fn-realm-recursive.js
vendored
Normal file
@ -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
|
The realm of a bound function exotic object is the realm of its target
|
||||||
function
|
function
|
||||||
info: |
|
info: |
|
||||||
|
7.3.22 GetFunctionRealm ( obj )
|
||||||
|
|
||||||
[...]
|
[...]
|
||||||
2. If obj has a [[Realm]] internal slot, then
|
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
|
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).
|
b. Return ? GetFunctionRealm(target).
|
||||||
features: [cross-realm]
|
features: [cross-realm]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var other = $262.createRealm().global;
|
var other = $262.createRealm().global;
|
||||||
var C = new other.Function();
|
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);
|
||||||
|
27
test/built-ins/Proxy/get-fn-realm-recursive.js
Normal file
27
test/built-ins/Proxy/get-fn-realm-recursive.js
Normal file
@ -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: >
|
description: >
|
||||||
The realm of a proxy exotic object is the realm of its target function
|
The realm of a proxy exotic object is the realm of its target function
|
||||||
info: |
|
info: |
|
||||||
|
7.3.22 GetFunctionRealm ( obj )
|
||||||
|
|
||||||
[...]
|
[...]
|
||||||
2. If obj has a [[Realm]] internal slot, then
|
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
|
[...]
|
||||||
[...]
|
|
||||||
4. If obj is a Proxy exotic object, then
|
4. If obj is a Proxy exotic object, then
|
||||||
a. If the value of the [[ProxyHandler]] internal slot of obj is null,
|
a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
|
||||||
throw a TypeError exception.
|
b. Let proxyTarget be obj.[[ProxyTarget]].
|
||||||
b. Let proxyTarget be the value of obj's [[ProxyTarget]] internal slot.
|
|
||||||
c. Return ? GetFunctionRealm(proxyTarget).
|
c. Return ? GetFunctionRealm(proxyTarget).
|
||||||
features: [cross-realm, Proxy]
|
features: [cross-realm, Proxy]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var other = $262.createRealm().global;
|
var other = $262.createRealm().global;
|
||||||
var C = new other.Function();
|
var C = new other.Function();
|
||||||
// Ensure that the proxy does not report a `prototype` property
|
C.prototype = null;
|
||||||
var P = new Proxy(C, {
|
var P = new Proxy(C, {});
|
||||||
get: function() {}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.sameValue(Object.getPrototypeOf(new P()), other.Object.prototype);
|
assert.sameValue(Object.getPrototypeOf(new P()), other.Object.prototype);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user