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