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.5.31-1.js |
michael@0 | 9 | |
michael@0 | 10 | ECMA Section: |
michael@0 | 11 | 15.9.5.31 Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] ) |
michael@0 | 12 | |
michael@0 | 13 | Description: |
michael@0 | 14 | |
michael@0 | 15 | If min is not specified, this behaves as if min were specified with |
michael@0 | 16 | the value getUTCMinutes( ). If sec is not specified, this behaves |
michael@0 | 17 | as if sec were specified with the value getUTCSeconds ( ). If ms |
michael@0 | 18 | is not specified, this behaves as if ms were specified with the |
michael@0 | 19 | value getUTCMilliseconds( ). |
michael@0 | 20 | |
michael@0 | 21 | 1.Let t be this time value. |
michael@0 | 22 | 2.Call ToNumber(hour). |
michael@0 | 23 | 3.If min is not specified, compute MinFromTime(t); |
michael@0 | 24 | otherwise, call ToNumber(min). |
michael@0 | 25 | 4.If sec is not specified, compute SecFromTime(t); |
michael@0 | 26 | otherwise, call ToNumber(sec). |
michael@0 | 27 | 5.If ms is not specified, compute msFromTime(t); |
michael@0 | 28 | otherwise, call ToNumber(ms). |
michael@0 | 29 | 6.Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). |
michael@0 | 30 | 7.Compute MakeDate(Day(t), Result(6)). |
michael@0 | 31 | 8.Set the [[Value]] property of the this value to TimeClip(Result(7)). |
michael@0 | 32 | |
michael@0 | 33 | 1.Return the value of the [[Value]] property of the this value. |
michael@0 | 34 | Author: christine@netscape.com |
michael@0 | 35 | Date: 12 november 1997 |
michael@0 | 36 | */ |
michael@0 | 37 | var SECTION = "15.9.5.31-1"; |
michael@0 | 38 | var VERSION = "ECMA_1"; |
michael@0 | 39 | startTest(); |
michael@0 | 40 | |
michael@0 | 41 | writeHeaderToLog(SECTION + |
michael@0 | 42 | " Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] )"); |
michael@0 | 43 | |
michael@0 | 44 | addNewTestCase( 0, 0, void 0, void 0, void 0, |
michael@0 | 45 | "TDATE = new Date(0);(TDATE).setUTCHours(0);TDATE", |
michael@0 | 46 | UTCDateFromTime(SetUTCHours(0,0,0,0)), |
michael@0 | 47 | LocalDateFromTime(SetUTCHours(0,0,0,0)) ); |
michael@0 | 48 | |
michael@0 | 49 | addNewTestCase( 28800000, 23, 59, 999, void 0, |
michael@0 | 50 | "TDATE = new Date(28800000);(TDATE).setUTCHours(23,59,999);TDATE", |
michael@0 | 51 | UTCDateFromTime(SetUTCHours(28800000,23,59,999)), |
michael@0 | 52 | LocalDateFromTime(SetUTCHours(28800000,23,59,999)) ); |
michael@0 | 53 | |
michael@0 | 54 | addNewTestCase( 28800000,999,999, void 0, void 0, |
michael@0 | 55 | "TDATE = new Date(28800000);(TDATE).setUTCHours(999,999);TDATE", |
michael@0 | 56 | UTCDateFromTime(SetUTCHours(28800000,999,999)), |
michael@0 | 57 | LocalDateFromTime(SetUTCHours(28800000,999,999)) ); |
michael@0 | 58 | |
michael@0 | 59 | addNewTestCase( 28800000, 999, void 0, void 0, void 0, |
michael@0 | 60 | "TDATE = new Date(28800000);(TDATE).setUTCHours(999);TDATE", |
michael@0 | 61 | UTCDateFromTime(SetUTCHours(28800000,999,0)), |
michael@0 | 62 | LocalDateFromTime(SetUTCHours(28800000,999,0)) ); |
michael@0 | 63 | |
michael@0 | 64 | addNewTestCase( 28800000, -8670, void 0, void 0, void 0, |
michael@0 | 65 | "TDATE = new Date(28800000);(TDATE).setUTCHours(-8670);TDATE", |
michael@0 | 66 | UTCDateFromTime(SetUTCHours(28800000,-8670)), |
michael@0 | 67 | LocalDateFromTime(SetUTCHours(28800000,-8670)) ); |
michael@0 | 68 | |
michael@0 | 69 | // modify hours to remove dst ambiguity |
michael@0 | 70 | addNewTestCase( 946684800000, 1235567, void 0, void 0, void 0, |
michael@0 | 71 | "TDATE = new Date(946684800000);(TDATE).setUTCHours(1235567);TDATE", |
michael@0 | 72 | UTCDateFromTime(SetUTCHours(946684800000,1235567)), |
michael@0 | 73 | LocalDateFromTime(SetUTCHours(946684800000,1235567)) ); |
michael@0 | 74 | |
michael@0 | 75 | addNewTestCase( -2208988800000, 59, 999, void 0, void 0, |
michael@0 | 76 | "TDATE = new Date(-2208988800000);(TDATE).setUTCHours(59,999);TDATE", |
michael@0 | 77 | UTCDateFromTime(SetUTCHours(-2208988800000,59,999)), |
michael@0 | 78 | LocalDateFromTime(SetUTCHours(-2208988800000,59,999)) ); |
michael@0 | 79 | |
michael@0 | 80 | test(); |
michael@0 | 81 | |
michael@0 | 82 | function addNewTestCase( time, hours, min, sec, ms, DateString, UTCDate, LocalDate) { |
michael@0 | 83 | |
michael@0 | 84 | DateCase = new Date(time); |
michael@0 | 85 | if ( min == void 0 ) { |
michael@0 | 86 | DateCase.setUTCHours( hours ); |
michael@0 | 87 | } else { |
michael@0 | 88 | if ( sec == void 0 ) { |
michael@0 | 89 | DateCase.setUTCHours( hours, min ); |
michael@0 | 90 | } else { |
michael@0 | 91 | if ( ms == void 0 ) { |
michael@0 | 92 | DateCase.setUTCHours( hours, min, sec ); |
michael@0 | 93 | } else { |
michael@0 | 94 | DateCase.setUTCHours( hours, min, sec, ms ); |
michael@0 | 95 | } |
michael@0 | 96 | } |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | new TestCase( SECTION, DateString+".getTime()", UTCDate.value, |
michael@0 | 100 | DateCase.getTime() ); |
michael@0 | 101 | new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, |
michael@0 | 102 | DateCase.valueOf() ); |
michael@0 | 103 | new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, |
michael@0 | 104 | DateCase.getUTCFullYear() ); |
michael@0 | 105 | new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, |
michael@0 | 106 | DateCase.getUTCMonth() ); |
michael@0 | 107 | new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, |
michael@0 | 108 | DateCase.getUTCDate() ); |
michael@0 | 109 | new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, |
michael@0 | 110 | DateCase.getUTCDay() ); |
michael@0 | 111 | new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, |
michael@0 | 112 | DateCase.getUTCHours() ); |
michael@0 | 113 | new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, |
michael@0 | 114 | DateCase.getUTCMinutes() ); |
michael@0 | 115 | new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, |
michael@0 | 116 | DateCase.getUTCSeconds() ); |
michael@0 | 117 | new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, |
michael@0 | 118 | DateCase.getUTCMilliseconds() ); |
michael@0 | 119 | |
michael@0 | 120 | new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, |
michael@0 | 121 | DateCase.getFullYear() ); |
michael@0 | 122 | new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, |
michael@0 | 123 | DateCase.getMonth() ); |
michael@0 | 124 | new TestCase( SECTION, DateString+".getDate()", LocalDate.date, |
michael@0 | 125 | DateCase.getDate() ); |
michael@0 | 126 | new TestCase( SECTION, DateString+".getDay()", LocalDate.day, |
michael@0 | 127 | DateCase.getDay() ); |
michael@0 | 128 | new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, |
michael@0 | 129 | DateCase.getHours() ); |
michael@0 | 130 | new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, |
michael@0 | 131 | DateCase.getMinutes() ); |
michael@0 | 132 | new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, |
michael@0 | 133 | DateCase.getSeconds() ); |
michael@0 | 134 | new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, |
michael@0 | 135 | DateCase.getMilliseconds() ); |
michael@0 | 136 | |
michael@0 | 137 | DateCase.toString = Object.prototype.toString; |
michael@0 | 138 | |
michael@0 | 139 | new TestCase( SECTION, |
michael@0 | 140 | DateString+".toString=Object.prototype.toString;" + |
michael@0 | 141 | DateString+".toString()", |
michael@0 | 142 | "[object Date]", |
michael@0 | 143 | DateCase.toString() ); |
michael@0 | 144 | } |
michael@0 | 145 | function MyDate() { |
michael@0 | 146 | this.year = 0; |
michael@0 | 147 | this.month = 0; |
michael@0 | 148 | this.date = 0; |
michael@0 | 149 | this.hours = 0; |
michael@0 | 150 | this.minutes = 0; |
michael@0 | 151 | this.seconds = 0; |
michael@0 | 152 | this.ms = 0; |
michael@0 | 153 | } |
michael@0 | 154 | function LocalDateFromTime(t) { |
michael@0 | 155 | t = LocalTime(t); |
michael@0 | 156 | return ( MyDateFromTime(t) ); |
michael@0 | 157 | } |
michael@0 | 158 | function UTCDateFromTime(t) { |
michael@0 | 159 | return ( MyDateFromTime(t) ); |
michael@0 | 160 | } |
michael@0 | 161 | function MyDateFromTime( t ) { |
michael@0 | 162 | var d = new MyDate(); |
michael@0 | 163 | d.year = YearFromTime(t); |
michael@0 | 164 | d.month = MonthFromTime(t); |
michael@0 | 165 | d.date = DateFromTime(t); |
michael@0 | 166 | d.hours = HourFromTime(t); |
michael@0 | 167 | d.minutes = MinFromTime(t); |
michael@0 | 168 | d.seconds = SecFromTime(t); |
michael@0 | 169 | d.ms = msFromTime(t); |
michael@0 | 170 | |
michael@0 | 171 | d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); |
michael@0 | 172 | d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); |
michael@0 | 173 | d.day = WeekDay( d.value ); |
michael@0 | 174 | |
michael@0 | 175 | return (d); |
michael@0 | 176 | } |
michael@0 | 177 | function SetUTCHours( t, hour, min, sec, ms ) { |
michael@0 | 178 | var TIME = t; |
michael@0 | 179 | var HOUR = Number(hour); |
michael@0 | 180 | var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); |
michael@0 | 181 | var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); |
michael@0 | 182 | var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); |
michael@0 | 183 | var RESULT6 = MakeTime( HOUR, |
michael@0 | 184 | MIN, |
michael@0 | 185 | SEC, |
michael@0 | 186 | MS ); |
michael@0 | 187 | return ( TimeClip(MakeDate(Day(TIME), RESULT6)) ); |
michael@0 | 188 | } |