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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /**
8 File Name: 15.9.4.2.js
9 ECMA Section: 15.9.4.2 Date.parse()
10 Description: The parse() function applies the to ToString() operator
11 to its argument and interprets the resulting string as
12 a date. It returns a number, the UTC time value
13 corresponding to the date.
15 The string may be interpreted as a local time, a UTC
16 time, or a time in some other time zone, depending on
17 the contents of the string.
19 (need to test strings containing stuff with the time
20 zone specified, and verify that parse() returns the
21 correct GMT time)
23 so for any Date object x, all of these things should
24 be equal:
26 value tested in function:
27 x.valueOf() test_value()
28 Date.parse(x.toString()) test_tostring()
29 Date.parse(x.toGMTString()) test_togmt()
31 Date.parse(x.toLocaleString()) is not required to
32 produce the same number value as the preceding three
33 expressions. in general the value produced by
34 Date.parse is implementation dependent when given any
35 string value that could not be produced in that
36 implementation by the toString or toGMTString method.
38 value tested in function:
39 Date.parse( x.toLocaleString()) test_tolocale()
41 Author: christine@netscape.com
42 Date: 10 july 1997
44 */
46 var VERSION = "ECMA_1";
47 startTest();
48 var SECTION = "15.9.4.2";
49 var TITLE = "Date.parse()";
51 var TIME = 0;
52 var UTC_YEAR = 1;
53 var UTC_MONTH = 2;
54 var UTC_DATE = 3;
55 var UTC_DAY = 4;
56 var UTC_HOURS = 5;
57 var UTC_MINUTES = 6;
58 var UTC_SECONDS = 7;
59 var UTC_MS = 8;
61 var YEAR = 9;
62 var MONTH = 10;
63 var DATE = 11;
64 var DAY = 12;
65 var HOURS = 13;
66 var MINUTES = 14;
67 var SECONDS = 15;
68 var MS = 16;
69 var TYPEOF = "object";
71 // for TCMS, the gTestcases array must be global.
72 writeHeaderToLog("15.9.4.2 Date.parse()" );
74 // Dates around 1970
76 addNewTestCase( new Date(0),
77 "new Date(0)",
78 [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
80 addNewTestCase( new Date(-1),
81 "new Date(-1)",
82 [-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] );
83 addNewTestCase( new Date(28799999),
84 "new Date(28799999)",
85 [28799999,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] );
86 addNewTestCase( new Date(28800000),
87 "new Date(28800000)",
88 [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
90 // Dates around 2000
92 addNewTestCase( new Date(946684799999),
93 "new Date(946684799999)",
94 [946684799999,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] );
95 addNewTestCase( new Date(946713599999),
96 "new Date(946713599999)",
97 [946713599999,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] );
98 addNewTestCase( new Date(946684800000),
99 "new Date(946684800000)",
100 [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
101 addNewTestCase( new Date(946713600000),
102 "new Date(946713600000)",
103 [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
105 // Dates around 1900
107 addNewTestCase( new Date(-2208988800000),
108 "new Date(-2208988800000)",
109 [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
111 addNewTestCase( new Date(-2208988800001),
112 "new Date(-2208988800001)",
113 [-2208988800001,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
115 addNewTestCase( new Date(-2208960000001),
116 "new Date(-2208960000001)",
117 [-2208960000001,1900,0,1,1,7,59,59,0,1899,11,31,0,23,59,59,999] );
118 addNewTestCase( new Date(-2208960000000),
119 "new Date(-2208960000000)",
120 [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
121 addNewTestCase( new Date(-2208959999999),
122 "new Date(-2208959999999)",
123 [-2208959999999,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
125 // Dates around Feb 29, 2000
127 var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour;
129 addNewTestCase( new Date(UTC_FEB_29_2000),
130 "new Date(" + UTC_FEB_29_2000 +")",
131 [UTC_FEB_29_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
132 addNewTestCase( new Date(PST_FEB_29_2000),
133 "new Date(" + PST_FEB_29_2000 +")",
134 [PST_FEB_29_2000,2000,0,1,6,8.0,0,0,2000,0,1,6,0,0,0,0]);
136 // Dates around Jan 1 2005
138 var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour;
140 addNewTestCase( new Date(UTC_JAN_1_2005),
141 "new Date("+ UTC_JAN_1_2005 +")",
142 [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
143 addNewTestCase( new Date(PST_JAN_1_2005),
144 "new Date("+ PST_JAN_1_2005 +")",
145 [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
148 test();
150 function addNewTestCase( DateCase, DateString, ResultArray ) {
151 DateCase = DateCase;
153 new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
154 new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
155 new TestCase( SECTION, "Date.parse(" + DateCase.toString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toString()) );
156 new TestCase( SECTION, "Date.parse(" + DateCase.toGMTString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toGMTString()) );
157 }