| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget |
| 5 |
es6id: 9.2.2 |
| 6 |
description: > |
| 7 |
Error retrieving function realm from revoked Proxy exotic object (honoring |
| 8 |
the Realm of the current execution context) |
| 9 |
info: | |
| 10 |
[...] |
| 11 |
5. If kind is "base", then |
| 12 |
a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget, |
| 13 |
"%ObjectPrototype%"). |
| 14 |
[...] |
| 15 |
|
| 16 |
9.1.13 OrdinaryCreateFromConstructor |
| 17 |
|
| 18 |
[...] |
| 19 |
2. Let proto be ? GetPrototypeFromConstructor(constructor, |
| 20 |
intrinsicDefaultProto). |
| 21 |
[...] |
| 22 |
|
| 23 |
9.1.14 GetPrototypeFromConstructor |
| 24 |
|
| 25 |
[...] |
| 26 |
3. Let proto be ? Get(constructor, "prototype"). |
| 27 |
4. If Type(proto) is not Object, then |
| 28 |
a. Let realm be ? GetFunctionRealm(constructor). |
| 29 |
|
| 30 |
7.3.22 GetFunctionRealm |
| 31 |
|
| 32 |
[...] |
| 33 |
2. If obj has a [[Realm]] internal slot, then |
| 34 |
[...] |
| 35 |
3. If obj is a Bound Function exotic object, then |
| 36 |
[...] |
| 37 |
4. If obj is a Proxy exotic object, then |
| 38 |
a. If the value of the [[ProxyHandler]] internal slot of obj is null, |
| 39 |
throw a TypeError exception. |
| 40 |
features: [cross-realm, Proxy] |
| 41 |
---*/ |
| 42 |
|
| 43 |
var other = $262.createRealm().global; |
| 44 |
// Defer proxy revocation until after the `constructor` property has been |
| 45 |
// accessed |
| 46 |
var handlers = { |
| 47 |
get: function() { |
| 48 |
handle.revoke(); |
| 49 |
} |
| 50 |
}; |
| 51 |
var handle = other.Proxy.revocable(function() {}, handlers); |
| 52 |
var f = handle.proxy; |
| 53 |
|
| 54 |
assert.sameValue(typeof f, 'function'); |
| 55 |
|
| 56 |
assert.throws(TypeError, function() { |
| 57 |
new f(); |
| 58 |
}); |