Debian Codegraph @

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

raw
1 load(libdir + "asserts.js");
2
3 // Throw a TypeError if Proxy is not called as a constructor
4 assertThrowsInstanceOf(function () { Proxy({}, {}); }, TypeError);
5
6 // Throw a TypeError if Proxy is called with less than two arguments
7 assertThrowsInstanceOf(function () { new Proxy(); }, TypeError);
8 assertThrowsInstanceOf(function () { new Proxy({}); }, TypeError);
9
10 // Throw a TypeError if the first argument is not a non-null object
11 assertThrowsInstanceOf(function () { new Proxy(0, {}); }, TypeError);
12 assertThrowsInstanceOf(function () { new Proxy(null, {}); }, TypeError);
13
14 // Throw a TypeError if the second argument is not a non-null object
15 assertThrowsInstanceOf(function () { new Proxy({}, 0); }, TypeError);
16 assertThrowsInstanceOf(function () { new Proxy({}, null); }, TypeError);
17
18 // Result of the call should be an object
19 assertEq(typeof new Proxy({}, {}), 'object');