Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommonn.org/licenses/publicdomain/
4 */
6 var BUGNUMBER = 645464;
7 var summary =
8 "[[DefaultValue]] behavior wrong for Date with overridden valueOf/toString";
10 print(BUGNUMBER + ": " + summary);
12 /**************
13 * BEGIN TEST *
14 **************/
16 function allTests()
17 {
18 var DS = new Date(2010, 1, 1).toString();
20 // equality
22 var d = new Date(2010, 1, 1);
23 assertEq(d == DS, true);
25 var d2 = new Date(2010, 1, 1);
26 d2.valueOf = function() { assertEq(arguments.length, 0); return 17; };
27 assertEq(d2 == DS, true);
29 var d3 = new Date(2010, 1, 1);
30 d3.toString = function() { return 42; };
31 assertEq(d3 == 42, true);
33 function testEquality()
34 {
35 var d = new Date(2010, 1, 1);
36 assertEq(d == DS, true);
38 var d2 = new Date(2010, 1, 1);
39 d2.valueOf = function() { assertEq(arguments.length, 0); return 17; };
40 assertEq(d2 == DS, true);
42 var d3 = new Date(2010, 1, 1);
43 d3.toString = function() { return 42; };
44 assertEq(d3 == 42, true);
45 }
46 testEquality();
49 // addition of Date to number
51 var d = new Date(2010, 1, 1);
52 assertEq(d + 5, DS + "5");
54 var d2 = new Date(2010, 1, 1);
55 d2.toString = function() { return 9; };
56 assertEq(d2 + 3, 9 + 3);
58 var d3 = new Date(2010, 1, 1);
59 d3.valueOf = function() { assertEq(arguments.length, 0); return 17; };
60 assertEq(d3 + 5, DS + "5");
62 function testDateNumberAddition()
63 {
64 var d = new Date(2010, 1, 1);
65 assertEq(d + 5, DS + "5");
67 var d2 = new Date(2010, 1, 1);
68 d2.toString = function() { return 9; };
69 assertEq(d2 + 3, 9 + 3);
71 var d3 = new Date(2010, 1, 1);
72 d3.valueOf = function() { assertEq(arguments.length, 0); return 17; };
73 assertEq(d3 + 5, DS + "5");
74 }
75 testDateNumberAddition();
78 // addition of Date to Date
80 var d = new Date(2010, 1, 1);
81 assertEq(d + d, DS + DS);
83 var d2 = new Date(2010, 1, 1);
84 d2.toString = function() { return 5; };
85 assertEq(d2 + d2, 10);
87 var d3 = new Date(2010, 1, 1);
88 d3.valueOf = function() { assertEq(arguments.length, 0); return 8.5; };
89 assertEq(d3 + d3, DS + DS);
91 function testDateDateAddition()
92 {
93 var d = new Date(2010, 1, 1);
94 assertEq(d + d, DS + DS);
96 var d2 = new Date(2010, 1, 1);
97 d2.toString = function() { return 5; };
98 assertEq(d2 + d2, 10);
100 var d3 = new Date(2010, 1, 1);
101 d3.valueOf = function() { assertEq(arguments.length, 0); return 8.5; };
102 assertEq(d3 + d3, DS + DS);
103 }
104 testDateDateAddition();
107 // Date as bracketed property name
109 var obj = { 8: 42, 9: 73 };
110 obj[DS] = 17;
112 var d = new Date(2010, 1, 1);
113 assertEq(obj[d], 17);
115 var d2 = new Date(2010, 1, 1);
116 d2.valueOf = function() { assertEq(arguments.length, 0); return 8; }
117 assertEq(obj[d2], 17);
119 var d3 = new Date(2010, 1, 1);
120 d3.toString = function() { return 9; };
121 assertEq(obj[d3], 73);
123 function testPropertyName()
124 {
125 var obj = { 8: 42, 9: 73 };
126 obj[DS] = 17;
128 var d = new Date(2010, 1, 1);
129 assertEq(obj[d], 17);
131 var d2 = new Date(2010, 1, 1);
132 d2.valueOf = function() { assertEq(arguments.length, 0); return 8; }
133 assertEq(obj[d2], 17);
135 var d3 = new Date(2010, 1, 1);
136 d3.toString = function() { return 9; };
137 assertEq(obj[d3], 73);
138 }
139 testPropertyName();
142 // Date as property name with |in| operator
144 var obj = {};
145 obj[DS] = 5;
147 var d = new Date(2010, 1, 1);
148 assertEq(d in obj, true);
150 var d2 = new Date(2010, 1, 1);
151 d2.toString = function() { return "baz"; };
152 assertEq(d2 in { baz: 42 }, true);
154 var d3 = new Date(2010, 1, 1);
155 d3.valueOf = function() { assertEq(arguments.length, 0); return "quux"; };
156 assertEq(d3 in obj, true);
158 function testInOperatorName()
159 {
160 var obj = {};
161 obj[DS] = 5;
163 var d = new Date(2010, 1, 1);
164 assertEq(d in obj, true);
166 var d2 = new Date(2010, 1, 1);
167 d2.toString = function() { return "baz"; };
168 assertEq(d2 in { baz: 42 }, true);
170 var d3 = new Date(2010, 1, 1);
171 d3.valueOf = function() { assertEq(arguments.length, 0); return "quux"; };
172 assertEq(d3 in obj, true);
173 }
174 testInOperatorName();
175 }
177 allTests();
179 if (typeof newGlobal === "function")
180 {
181 Date = newGlobal().Date;
182 allTests();
183 }
185 /******************************************************************************/
187 if (typeof reportCompare === "function")
188 reportCompare(true, true);
190 print("All tests passed!");