diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js b/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js new file mode 100644 index 0000000000..6063f64101 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js @@ -0,0 +1,59 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + Error retrieving function realm from revoked Proxy exotic object (honoring + the Realm of the current execution context) +info: | + [...] + 5. If kind is "base", then + a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget, + "%ObjectPrototype%"). + [...] + + 9.1.13 OrdinaryCreateFromConstructor + + [...] + 2. Let proto be ? GetPrototypeFromConstructor(constructor, + intrinsicDefaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + + 7.3.22 GetFunctionRealm + + [...] + 2. If obj has a [[Realm]] internal slot, then + [...] + 3. If obj is a Bound Function 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, + throw a TypeError exception. +features: [cross-realm, Proxy] +---*/ + +var other = $262.createRealm().global; +// Defer proxy revocation until after the `constructor` property has been +// accessed +var handlers = { + get: function() { + handle.revoke(); + } +}; +var handle = other.Proxy.revocable(function() {}, handlers); +var f = handle.proxy; + +assert.sameValue(typeof f, 'function'); + +assert.throws(TypeError, function() { + new f(); +}); + +reportCompare(0, 0); |