summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/proxy/testDirectProxyConstruct5.js
blob: e86bc456facae0641f6b5bf2d2a45335b871ad28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
load(libdir + "asserts.js");

// Make sure that a proxy only has a [[Construct]] if the target does

var handler = {};
var p = new Proxy(Math.sin, handler);
var r = Proxy.revocable(Math.sin, handler).proxy;

assertThrowsInstanceOf(() => new p, TypeError, "Can't use 'new' on proxy with non-constructor target");
assertThrowsInstanceOf(() => new r, TypeError, "Can't use 'new' on proxy with non-constructor target");
// Better throw regardless of whether we have a handler trap.
handler.construct = (() => ({}));
assertThrowsInstanceOf(() => new p, TypeError, "Can't use 'new' on proxy with non-constructor target");
assertThrowsInstanceOf(() => new r, TypeError, "Can't use 'new' on proxy with non-constructor target");