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.
1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
4 //-----------------------------------------------------------------------------
5 var BUGNUMBER = 732669;
6 var summary = "Primitive values don't box correctly";
8 print(BUGNUMBER + ": " + summary);
10 /**************
11 * BEGIN TEST *
12 **************/
14 var t;
15 function returnThis() { return this; }
17 // Boolean
19 Boolean.prototype.method = returnThis;
20 t = true.method();
21 assertEq(t !== Boolean.prototype, true);
22 assertEq(t.toString(), "true");
24 Object.defineProperty(Boolean.prototype, "property", { get: returnThis, configurable: true });
25 t = false.property;
26 assertEq(t !== Boolean.prototype, true);
27 assertEq(t.toString(), "false");
29 delete Boolean.prototype.method;
30 delete Boolean.prototype.property;
33 // Number
35 Number.prototype.method = returnThis;
36 t = 5..method();
37 assertEq(t !== Number.prototype, true);
38 assertEq(t.toString(), "5");
40 Object.defineProperty(Number.prototype, "property", { get: returnThis, configurable: true });
41 t = 17..property;
42 assertEq(t !== Number.prototype, true);
43 assertEq(t.toString(), "17");
45 delete Number.prototype.method;
46 delete Number.prototype.property;
49 // String
51 String.prototype.method = returnThis;
52 t = "foo".method();
53 assertEq(t !== String.prototype, true);
54 assertEq(t.toString(), "foo");
56 Object.defineProperty(String.prototype, "property", { get: returnThis, configurable: true });
57 t = "bar".property;
58 assertEq(t !== String.prototype, true);
59 assertEq(t.toString(), "bar");
61 delete String.prototype.method;
62 delete String.prototype.property;
65 // Object
67 Object.prototype.method = returnThis;
69 t = true.method();
70 assertEq(t !== Object.prototype, true);
71 assertEq(t !== Boolean.prototype, true);
72 assertEq(t.toString(), "true");
74 t = 42..method();
75 assertEq(t !== Object.prototype, true);
76 assertEq(t !== Number.prototype, true);
77 assertEq(t.toString(), "42");
79 t = "foo".method();
80 assertEq(t !== Object.prototype, true);
81 assertEq(t !== String.prototype, true);
82 assertEq(t.toString(), "foo");
84 Object.defineProperty(Object.prototype, "property", { get: returnThis, configurable: true });
86 t = false.property;
87 assertEq(t !== Object.prototype, true);
88 assertEq(t !== Boolean.prototype, true);
89 assertEq(t.toString(), "false");
91 t = 8675309..property;
92 assertEq(t !== Object.prototype, true);
93 assertEq(t !== Number.prototype, true);
94 assertEq(t.toString(), "8675309");
96 t = "bar".property;
97 assertEq(t !== Object.prototype, true);
98 assertEq(t !== String.prototype, true);
99 assertEq(t.toString(), "bar");
101 /******************************************************************************/
103 if (typeof reportCompare === "function")
104 reportCompare(true, true);
106 print("Tests complete");