diff --git a/test/built-ins/Function/prototype/bind/get-fn-realm-recursive.js b/test/built-ins/Function/prototype/bind/get-fn-realm-recursive.js new file mode 100644 index 0000000000..7e91dbdf49 --- /dev/null +++ b/test/built-ins/Function/prototype/bind/get-fn-realm-recursive.js @@ -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); diff --git a/test/built-ins/Function/prototype/bind/get-fn-realm.js b/test/built-ins/Function/prototype/bind/get-fn-realm.js index 104aac2eab..4bdaa88faa 100644 --- a/test/built-ins/Function/prototype/bind/get-fn-realm.js +++ b/test/built-ins/Function/prototype/bind/get-fn-realm.js @@ -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); diff --git a/test/built-ins/Proxy/get-fn-realm-recursive.js b/test/built-ins/Proxy/get-fn-realm-recursive.js new file mode 100644 index 0000000000..488e13a936 --- /dev/null +++ b/test/built-ins/Proxy/get-fn-realm-recursive.js @@ -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); diff --git a/test/built-ins/Proxy/get-fn-realm.js b/test/built-ins/Proxy/get-fn-realm.js index 4dc7a9b3f7..b93ee9718a 100644 --- a/test/built-ins/Proxy/get-fn-realm.js +++ b/test/built-ins/Proxy/get-fn-realm.js @@ -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);