|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/licenses/publicdomain/ |
|
4 */ |
|
5 |
|
6 function checkConstruct(thing, buggy) { |
|
7 try { |
|
8 new thing(); |
|
9 assertEq(0, 1, "not reached " + thing); |
|
10 } catch (e) { |
|
11 if (buggy) |
|
12 assertEq(String(e.message).indexOf("is not a constructor") === -1, false); |
|
13 else |
|
14 assertEq(String(e.message).indexOf("thing is not a constructor") === -1, false); |
|
15 } |
|
16 } |
|
17 |
|
18 var re = /aaa/ |
|
19 checkConstruct(re, false); |
|
20 |
|
21 var boundFunctionPrototype = Function.prototype.bind(); |
|
22 checkConstruct(boundFunctionPrototype, true); |
|
23 |
|
24 var boundBuiltin = Math.sin.bind(); |
|
25 checkConstruct(boundBuiltin, true); |
|
26 |
|
27 /* We set the proxies construct trap to undefined, |
|
28 * so the call trap is used as constructor. |
|
29 */ |
|
30 |
|
31 var proxiedFunctionPrototype = Proxy.create({}, Function.prototype, undefined); |
|
32 checkConstruct(proxiedFunctionPrototype, false); |
|
33 |
|
34 var proxiedBuiltin = Proxy.create({}, parseInt, undefined); |
|
35 checkConstruct(proxiedBuiltin, false); |
|
36 |
|
37 |
|
38 if (typeof reportCompare == 'function') |
|
39 reportCompare(0, 0, "ok"); |