Debian Codegraph @

js/src/jit-test/tests/proxy/testDirectProxyConstruct5.js

raw
1 load(libdir + "asserts.js");
2
3 // Make sure that a proxy only has a [[Construct]] if the target does
4
5 var handler = {};
6 var p = new Proxy(Math.sin, handler);
7 var r = Proxy.revocable(Math.sin, handler).proxy;
8
9 assertThrowsInstanceOf(() => new p, TypeError, "Can't use 'new' on proxy with non-constructor target");
10 assertThrowsInstanceOf(() => new r, TypeError, "Can't use 'new' on proxy with non-constructor target");
11 // Better throw regardless of whether we have a handler trap.
12 handler.construct = (() => ({}));
13 assertThrowsInstanceOf(() => new p, TypeError, "Can't use 'new' on proxy with non-constructor target");
14 assertThrowsInstanceOf(() => new r, TypeError, "Can't use 'new' on proxy with non-constructor target");