Debian Codegraph @

js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js

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