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