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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 15.9.3.1.js |
michael@0 | 9 | ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) |
michael@0 | 10 | Description: The [[Prototype]] property of the newly constructed |
michael@0 | 11 | object is set to the original Date prototype object, |
michael@0 | 12 | the one that is the initial value of Date.prototype. |
michael@0 | 13 | |
michael@0 | 14 | The [[Class]] property of the newly constructed object |
michael@0 | 15 | is set as follows: |
michael@0 | 16 | 1. Call ToNumber(year) |
michael@0 | 17 | 2. Call ToNumber(month) |
michael@0 | 18 | 3. Call ToNumber(date) |
michael@0 | 19 | 4. Call ToNumber(hours) |
michael@0 | 20 | 5. Call ToNumber(minutes) |
michael@0 | 21 | 6. Call ToNumber(seconds) |
michael@0 | 22 | 7. Call ToNumber(ms) |
michael@0 | 23 | 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= |
michael@0 | 24 | 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, |
michael@0 | 25 | Result(8) is Result(1) |
michael@0 | 26 | 9. Compute MakeDay(Result(8), Result(2), Result(3) |
michael@0 | 27 | 10. Compute MakeTime(Result(4), Result(5), Result(6), |
michael@0 | 28 | Result(7) |
michael@0 | 29 | 11. Compute MakeDate(Result(9), Result(10)) |
michael@0 | 30 | 12. Set the [[Value]] property of the newly constructed |
michael@0 | 31 | object to TimeClip(UTC(Result(11))). |
michael@0 | 32 | |
michael@0 | 33 | |
michael@0 | 34 | This tests the returned value of a newly constructed |
michael@0 | 35 | Date object. |
michael@0 | 36 | |
michael@0 | 37 | Author: christine@netscape.com |
michael@0 | 38 | Date: 7 july 1997 |
michael@0 | 39 | */ |
michael@0 | 40 | |
michael@0 | 41 | var SECTION = "15.9.3.1"; |
michael@0 | 42 | var VERSION = "ECMA_1"; |
michael@0 | 43 | startTest(); |
michael@0 | 44 | var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; |
michael@0 | 45 | |
michael@0 | 46 | var TIME = 0; |
michael@0 | 47 | var UTC_YEAR = 1; |
michael@0 | 48 | var UTC_MONTH = 2; |
michael@0 | 49 | var UTC_DATE = 3; |
michael@0 | 50 | var UTC_DAY = 4; |
michael@0 | 51 | var UTC_HOURS = 5; |
michael@0 | 52 | var UTC_MINUTES = 6; |
michael@0 | 53 | var UTC_SECONDS = 7; |
michael@0 | 54 | var UTC_MS = 8; |
michael@0 | 55 | |
michael@0 | 56 | var YEAR = 9; |
michael@0 | 57 | var MONTH = 10; |
michael@0 | 58 | var DATE = 11; |
michael@0 | 59 | var DAY = 12; |
michael@0 | 60 | var HOURS = 13; |
michael@0 | 61 | var MINUTES = 14; |
michael@0 | 62 | var SECONDS = 15; |
michael@0 | 63 | var MS = 16; |
michael@0 | 64 | |
michael@0 | 65 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 66 | |
michael@0 | 67 | // Dates around 1970 |
michael@0 | 68 | |
michael@0 | 69 | addNewTestCase( new Date( 1969,11,31,15,59,59,999), |
michael@0 | 70 | "new Date( 1969,11,31,15,59,59,999)", |
michael@0 | 71 | [TIME_1970-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); |
michael@0 | 72 | |
michael@0 | 73 | addNewTestCase( new Date( 1969,11,31,23,59,59,999), |
michael@0 | 74 | "new Date( 1969,11,31,23,59,59,999)", |
michael@0 | 75 | [TIME_1970-PST_ADJUST-1,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); |
michael@0 | 76 | |
michael@0 | 77 | addNewTestCase( new Date( 1970,0,1,0,0,0,0), |
michael@0 | 78 | "new Date( 1970,0,1,0,0,0,0)", |
michael@0 | 79 | [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); |
michael@0 | 80 | |
michael@0 | 81 | addNewTestCase( new Date( 1969,11,31,16,0,0,0), |
michael@0 | 82 | "new Date( 1969,11,31,16,0,0,0)", |
michael@0 | 83 | [TIME_1970,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); |
michael@0 | 84 | |
michael@0 | 85 | addNewTestCase( new Date(1969,12,1,0,0,0,0), |
michael@0 | 86 | "new Date(1969,12,1,0,0,0,0)", |
michael@0 | 87 | [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); |
michael@0 | 88 | |
michael@0 | 89 | addNewTestCase( new Date(1969,11,32,0,0,0,0), |
michael@0 | 90 | "new Date(1969,11,32,0,0,0,0)", |
michael@0 | 91 | [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); |
michael@0 | 92 | |
michael@0 | 93 | addNewTestCase( new Date(1969,11,31,24,0,0,0), |
michael@0 | 94 | "new Date(1969,11,31,24,0,0,0)", |
michael@0 | 95 | [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); |
michael@0 | 96 | |
michael@0 | 97 | addNewTestCase( new Date(1969,11,31,23,60,0,0), |
michael@0 | 98 | "new Date(1969,11,31,23,60,0,0)", |
michael@0 | 99 | [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); |
michael@0 | 100 | |
michael@0 | 101 | addNewTestCase( new Date(1969,11,31,23,59,60,0), |
michael@0 | 102 | "new Date(1969,11,31,23,59,60,0)", |
michael@0 | 103 | [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); |
michael@0 | 104 | |
michael@0 | 105 | addNewTestCase( new Date(1969,11,31,23,59,59,1000), |
michael@0 | 106 | "new Date(1969,11,31,23,59,59,1000)", |
michael@0 | 107 | [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); |
michael@0 | 108 | |
michael@0 | 109 | // Dates around 2000 |
michael@0 | 110 | |
michael@0 | 111 | addNewTestCase( new Date( 1999,11,31,15,59,59,999), |
michael@0 | 112 | "new Date( 1999,11,31,15,59,59,999)", |
michael@0 | 113 | [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); |
michael@0 | 114 | |
michael@0 | 115 | addNewTestCase( new Date( 1999,11,31,16,0,0,0), |
michael@0 | 116 | "new Date( 1999,11,31,16,0,0,0)", |
michael@0 | 117 | [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); |
michael@0 | 118 | |
michael@0 | 119 | addNewTestCase( new Date( 1999,11,31,23,59,59,999), |
michael@0 | 120 | "new Date( 1999,11,31,23,59,59,999)", |
michael@0 | 121 | [TIME_2000-PST_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); |
michael@0 | 122 | |
michael@0 | 123 | addNewTestCase( new Date( 2000,0,1,0,0,0,0), |
michael@0 | 124 | "new Date( 2000,0,1,0,0,0,0)", |
michael@0 | 125 | [TIME_2000-PST_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); |
michael@0 | 126 | |
michael@0 | 127 | addNewTestCase( new Date( 2000,0,1,0,0,0,1), |
michael@0 | 128 | "new Date( 2000,0,1,0,0,0,1)", |
michael@0 | 129 | [TIME_2000-PST_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); |
michael@0 | 130 | |
michael@0 | 131 | // Dates around 29 Feb 2000 |
michael@0 | 132 | |
michael@0 | 133 | addNewTestCase( new Date(2000,1,28,16,0,0,0), |
michael@0 | 134 | "new Date(2000,1,28,16,0,0,0)", |
michael@0 | 135 | [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); |
michael@0 | 136 | |
michael@0 | 137 | addNewTestCase( new Date(2000,1,29,0,0,0,0), |
michael@0 | 138 | "new Date(2000,1,29,0,0,0,0)", |
michael@0 | 139 | [UTC_FEB_29_2000-PST_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); |
michael@0 | 140 | |
michael@0 | 141 | addNewTestCase( new Date(2000,1,28,24,0,0,0), |
michael@0 | 142 | "new Date(2000,1,28,24,0,0,0)", |
michael@0 | 143 | [UTC_FEB_29_2000-PST_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); |
michael@0 | 144 | |
michael@0 | 145 | // Dates around 1900 |
michael@0 | 146 | |
michael@0 | 147 | addNewTestCase( new Date(1899,11,31,16,0,0,0), |
michael@0 | 148 | "new Date(1899,11,31,16,0,0,0)", |
michael@0 | 149 | [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); |
michael@0 | 150 | |
michael@0 | 151 | addNewTestCase( new Date(1899,11,31,15,59,59,999), |
michael@0 | 152 | "new Date(1899,11,31,15,59,59,999)", |
michael@0 | 153 | [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); |
michael@0 | 154 | |
michael@0 | 155 | addNewTestCase( new Date(1899,11,31,23,59,59,999), |
michael@0 | 156 | "new Date(1899,11,31,23,59,59,999)", |
michael@0 | 157 | [TIME_1900-PST_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); |
michael@0 | 158 | |
michael@0 | 159 | addNewTestCase( new Date(1900,0,1,0,0,0,0), |
michael@0 | 160 | "new Date(1900,0,1,0,0,0,0)", |
michael@0 | 161 | [TIME_1900-PST_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); |
michael@0 | 162 | |
michael@0 | 163 | addNewTestCase( new Date(1900,0,1,0,0,0,1), |
michael@0 | 164 | "new Date(1900,0,1,0,0,0,1)", |
michael@0 | 165 | [TIME_1900-PST_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); |
michael@0 | 166 | |
michael@0 | 167 | // Dates around 2005 |
michael@0 | 168 | |
michael@0 | 169 | addNewTestCase( new Date(2005,0,1,0,0,0,0), |
michael@0 | 170 | "new Date(2005,0,1,0,0,0,0)", |
michael@0 | 171 | [UTC_JAN_1_2005-PST_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); |
michael@0 | 172 | |
michael@0 | 173 | addNewTestCase( new Date(2004,11,31,16,0,0,0), |
michael@0 | 174 | "new Date(2004,11,31,16,0,0,0)", |
michael@0 | 175 | [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); |
michael@0 | 176 | |
michael@0 | 177 | test(); |
michael@0 | 178 | |
michael@0 | 179 | |
michael@0 | 180 | function addNewTestCase( DateCase, DateString, ResultArray ) { |
michael@0 | 181 | //adjust hard-coded ResultArray for tester's timezone instead of PST |
michael@0 | 182 | adjustResultArray(ResultArray); |
michael@0 | 183 | |
michael@0 | 184 | new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); |
michael@0 | 185 | new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); |
michael@0 | 186 | |
michael@0 | 187 | new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); |
michael@0 | 188 | new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); |
michael@0 | 189 | new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); |
michael@0 | 190 | new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); |
michael@0 | 191 | new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); |
michael@0 | 192 | new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); |
michael@0 | 193 | new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); |
michael@0 | 194 | new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); |
michael@0 | 195 | |
michael@0 | 196 | new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); |
michael@0 | 197 | new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); |
michael@0 | 198 | new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); |
michael@0 | 199 | new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); |
michael@0 | 200 | new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); |
michael@0 | 201 | new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); |
michael@0 | 202 | new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); |
michael@0 | 203 | new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); |
michael@0 | 204 | } |
michael@0 | 205 |