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 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | |
michael@0 | 3 | /* |
michael@0 | 4 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 5 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | var obj = {} |
michael@0 | 9 | |
michael@0 | 10 | function strict() { "use strict"; return this; } |
michael@0 | 11 | assertEq(strict.call(""), ""); |
michael@0 | 12 | assertEq(strict.call(true), true); |
michael@0 | 13 | assertEq(strict.call(42), 42); |
michael@0 | 14 | assertEq(strict.call(null), null); |
michael@0 | 15 | assertEq(strict.call(undefined), undefined); |
michael@0 | 16 | assertEq(strict.call(obj), obj); |
michael@0 | 17 | assertEq(new strict() instanceof Object, true); |
michael@0 | 18 | |
michael@0 | 19 | /* |
michael@0 | 20 | * The compiler internally converts x['foo'] to x.foo. Writing x[s] where |
michael@0 | 21 | * s='foo' is enough to throw it off the scent for now. |
michael@0 | 22 | */ |
michael@0 | 23 | var strictString = 'strict'; |
michael@0 | 24 | |
michael@0 | 25 | Boolean.prototype.strict = strict; |
michael@0 | 26 | assertEq(true.strict(), true); |
michael@0 | 27 | assertEq(true[strictString](), true); |
michael@0 | 28 | |
michael@0 | 29 | Number.prototype.strict = strict; |
michael@0 | 30 | assertEq((42).strict(), 42); |
michael@0 | 31 | assertEq(42[strictString](), 42); |
michael@0 | 32 | |
michael@0 | 33 | String.prototype.strict = strict; |
michael@0 | 34 | assertEq("".strict(), ""); |
michael@0 | 35 | assertEq(""[strictString](), ""); |
michael@0 | 36 | |
michael@0 | 37 | function lenient() { return this; } |
michael@0 | 38 | assertEq(lenient.call("") instanceof String, true); |
michael@0 | 39 | assertEq(lenient.call(true) instanceof Boolean, true); |
michael@0 | 40 | assertEq(lenient.call(42) instanceof Number, true); |
michael@0 | 41 | assertEq(lenient.call(null), this); |
michael@0 | 42 | assertEq(lenient.call(undefined), this); |
michael@0 | 43 | assertEq(lenient.call(obj), obj); |
michael@0 | 44 | assertEq(new lenient() instanceof Object, true); |
michael@0 | 45 | |
michael@0 | 46 | var lenientString = 'lenient'; |
michael@0 | 47 | |
michael@0 | 48 | Boolean.prototype.lenient = lenient; |
michael@0 | 49 | assertEq(true.lenient() instanceof Boolean, true); |
michael@0 | 50 | assertEq(true[lenientString]() instanceof Boolean, true); |
michael@0 | 51 | |
michael@0 | 52 | Number.prototype.lenient = lenient; |
michael@0 | 53 | assertEq(42[lenientString]() instanceof Number, true); |
michael@0 | 54 | |
michael@0 | 55 | String.prototype.lenient = lenient; |
michael@0 | 56 | assertEq(""[lenientString]() instanceof String, true); |
michael@0 | 57 | |
michael@0 | 58 | reportCompare(true, true); |