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 | var SECTION = "15.9.4.3"; |
michael@0 | 8 | var TITLE = "Date.UTC( year, month, date, hours, minutes, seconds, ms )"; |
michael@0 | 9 | |
michael@0 | 10 | // Dates around 1970 |
michael@0 | 11 | |
michael@0 | 12 | addNewTestCase( Date.UTC( 1970,0,1,0,0,0,0), |
michael@0 | 13 | "Date.UTC( 1970,0,1,0,0,0,0)", |
michael@0 | 14 | utc(1970,0,1,0,0,0,0) ); |
michael@0 | 15 | |
michael@0 | 16 | addNewTestCase( Date.UTC( 1969,11,31,23,59,59,999), |
michael@0 | 17 | "Date.UTC( 1969,11,31,23,59,59,999)", |
michael@0 | 18 | utc(1969,11,31,23,59,59,999) ); |
michael@0 | 19 | addNewTestCase( Date.UTC( 1972,1,29,23,59,59,999), |
michael@0 | 20 | "Date.UTC( 1972,1,29,23,59,59,999)", |
michael@0 | 21 | utc(1972,1,29,23,59,59,999) ); |
michael@0 | 22 | addNewTestCase( Date.UTC( 1972,2,1,23,59,59,999), |
michael@0 | 23 | "Date.UTC( 1972,2,1,23,59,59,999)", |
michael@0 | 24 | utc(1972,2,1,23,59,59,999) ); |
michael@0 | 25 | addNewTestCase( Date.UTC( 1968,1,29,23,59,59,999), |
michael@0 | 26 | "Date.UTC( 1968,1,29,23,59,59,999)", |
michael@0 | 27 | utc(1968,1,29,23,59,59,999) ); |
michael@0 | 28 | addNewTestCase( Date.UTC( 1968,2,1,23,59,59,999), |
michael@0 | 29 | "Date.UTC( 1968,2,1,23,59,59,999)", |
michael@0 | 30 | utc(1968,2,1,23,59,59,999) ); |
michael@0 | 31 | addNewTestCase( Date.UTC( 1969,0,1,0,0,0,0), |
michael@0 | 32 | "Date.UTC( 1969,0,1,0,0,0,0)", |
michael@0 | 33 | utc(1969,0,1,0,0,0,0) ); |
michael@0 | 34 | addNewTestCase( Date.UTC( 1969,11,31,23,59,59,1000), |
michael@0 | 35 | "Date.UTC( 1969,11,31,23,59,59,1000)", |
michael@0 | 36 | utc(1970,0,1,0,0,0,0) ); |
michael@0 | 37 | addNewTestCase( Date.UTC( 1969,Number.NaN,31,23,59,59,999), |
michael@0 | 38 | "Date.UTC( 1969,Number.NaN,31,23,59,59,999)", |
michael@0 | 39 | utc(1969,Number.NaN,31,23,59,59,999) ); |
michael@0 | 40 | |
michael@0 | 41 | // Dates around 2000 |
michael@0 | 42 | |
michael@0 | 43 | addNewTestCase( Date.UTC( 1999,11,31,23,59,59,999), |
michael@0 | 44 | "Date.UTC( 1999,11,31,23,59,59,999)", |
michael@0 | 45 | utc(1999,11,31,23,59,59,999) ); |
michael@0 | 46 | addNewTestCase( Date.UTC( 2000,0,1,0,0,0,0), |
michael@0 | 47 | "Date.UTC( 2000,0,1,0,0,0,0)", |
michael@0 | 48 | utc(2000,0,1,0,0,0,0) ); |
michael@0 | 49 | |
michael@0 | 50 | // Dates around 1900 |
michael@0 | 51 | addNewTestCase( Date.UTC( 1899,11,31,23,59,59,999), |
michael@0 | 52 | "Date.UTC( 1899,11,31,23,59,59,999)", |
michael@0 | 53 | utc(1899,11,31,23,59,59,999) ); |
michael@0 | 54 | addNewTestCase( Date.UTC( 1900,0,1,0,0,0,0), |
michael@0 | 55 | "Date.UTC( 1900,0,1,0,0,0,0)", |
michael@0 | 56 | utc(1900,0,1,0,0,0,0) ); |
michael@0 | 57 | addNewTestCase( Date.UTC( 1973,0,1,0,0,0,0), |
michael@0 | 58 | "Date.UTC( 1973,0,1,0,0,0,0)", |
michael@0 | 59 | utc(1973,0,1,0,0,0,0) ); |
michael@0 | 60 | addNewTestCase( Date.UTC( 1776,6,4,12,36,13,111), |
michael@0 | 61 | "Date.UTC( 1776,6,4,12,36,13,111)", |
michael@0 | 62 | utc(1776,6,4,12,36,13,111) ); |
michael@0 | 63 | addNewTestCase( Date.UTC( 2525,9,18,15,30,1,123), |
michael@0 | 64 | "Date.UTC( 2525,9,18,15,30,1,123)", |
michael@0 | 65 | utc(2525,9,18,15,30,1,123) ); |
michael@0 | 66 | |
michael@0 | 67 | // Dates around 29 Feb 2000 |
michael@0 | 68 | |
michael@0 | 69 | addNewTestCase( Date.UTC( 2000,1,29,0,0,0,0 ), |
michael@0 | 70 | "Date.UTC( 2000,1,29,0,0,0,0 )", |
michael@0 | 71 | utc(2000,1,29,0,0,0,0) ); |
michael@0 | 72 | addNewTestCase( Date.UTC( 2000,1,29,8,0,0,0 ), |
michael@0 | 73 | "Date.UTC( 2000,1,29,8,0,0,0 )", |
michael@0 | 74 | utc(2000,1,29,8,0,0,0) ); |
michael@0 | 75 | |
michael@0 | 76 | // Dates around 1 Jan 2005 |
michael@0 | 77 | |
michael@0 | 78 | addNewTestCase( Date.UTC( 2005,0,1,0,0,0,0 ), |
michael@0 | 79 | "Date.UTC( 2005,0,1,0,0,0,0 )", |
michael@0 | 80 | utc(2005,0,1,0,0,0,0) ); |
michael@0 | 81 | addNewTestCase( Date.UTC( 2004,11,31,16,0,0,0 ), |
michael@0 | 82 | "Date.UTC( 2004,11,31,16,0,0,0 )", |
michael@0 | 83 | utc(2004,11,31,16,0,0,0) ); |
michael@0 | 84 | |
michael@0 | 85 | test(); |
michael@0 | 86 | |
michael@0 | 87 | function addNewTestCase( DateCase, DateString, ExpectDate) { |
michael@0 | 88 | DateCase = DateCase; |
michael@0 | 89 | |
michael@0 | 90 | new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); |
michael@0 | 91 | new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | function MyDate() { |
michael@0 | 95 | this.year = 0; |
michael@0 | 96 | this.month = 0; |
michael@0 | 97 | this.date = 0; |
michael@0 | 98 | this.hours = 0; |
michael@0 | 99 | this.minutes = 0; |
michael@0 | 100 | this.seconds = 0; |
michael@0 | 101 | this.ms = 0; |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | function utc( year, month, date, hours, minutes, seconds, ms ) { |
michael@0 | 105 | d = new MyDate(); |
michael@0 | 106 | d.year = Number(year); |
michael@0 | 107 | |
michael@0 | 108 | if (month) |
michael@0 | 109 | d.month = Number(month); |
michael@0 | 110 | if (date) |
michael@0 | 111 | d.date = Number(date); |
michael@0 | 112 | if (hours) |
michael@0 | 113 | d.hours = Number(hours); |
michael@0 | 114 | if (minutes) |
michael@0 | 115 | d.minutes = Number(minutes); |
michael@0 | 116 | if (seconds) |
michael@0 | 117 | d.seconds = Number(seconds); |
michael@0 | 118 | if (ms) |
michael@0 | 119 | d.ms = Number(ms); |
michael@0 | 120 | |
michael@0 | 121 | if ( isNaN(d.year) && 0 <= ToInteger(d.year) && d.year <= 99 ) { |
michael@0 | 122 | d.year = 1900 + ToInteger(d.year); |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | if (isNaN(month) || isNaN(year) || isNaN(date) || isNaN(hours) || |
michael@0 | 126 | isNaN(minutes) || isNaN(seconds) || isNaN(ms) ) { |
michael@0 | 127 | d.year = Number.NaN; |
michael@0 | 128 | d.month = Number.NaN; |
michael@0 | 129 | d.date = Number.NaN; |
michael@0 | 130 | d.hours = Number.NaN; |
michael@0 | 131 | d.minutes = Number.NaN; |
michael@0 | 132 | d.seconds = Number.NaN; |
michael@0 | 133 | d.ms = Number.NaN; |
michael@0 | 134 | d.value = Number.NaN; |
michael@0 | 135 | d.time = Number.NaN; |
michael@0 | 136 | d.day =Number.NaN; |
michael@0 | 137 | return d; |
michael@0 | 138 | } |
michael@0 | 139 | |
michael@0 | 140 | d.day = MakeDay( d.year, d.month, d.date ); |
michael@0 | 141 | d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); |
michael@0 | 142 | d.value = (TimeClip( MakeDate(d.day,d.time))); |
michael@0 | 143 | |
michael@0 | 144 | return d; |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | function UTCTime( t ) { |
michael@0 | 148 | sign = ( t < 0 ) ? -1 : 1; |
michael@0 | 149 | return ( (t +(TZ_DIFF*msPerHour)) ); |
michael@0 | 150 | } |
michael@0 | 151 |