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.25-1.js |
michael@0 | 9 | ECMA Section: 15.9.5.25 Date.prototype.setUTCMilliseconds(ms) |
michael@0 | 10 | Description: |
michael@0 | 11 | 1. Let t be this time value. |
michael@0 | 12 | 2. Call ToNumber(ms). |
michael@0 | 13 | 3. Compute MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), Result(2)). |
michael@0 | 14 | 4. Compute MakeDate(Day(t), Result(3)). |
michael@0 | 15 | 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). |
michael@0 | 16 | 6. Return the value of the [[Value]] property of the this value. |
michael@0 | 17 | Author: christine@netscape.com |
michael@0 | 18 | Date: 12 november 1997 |
michael@0 | 19 | */ |
michael@0 | 20 | var SECTION = "15.9.5.25-1"; |
michael@0 | 21 | var VERSION = "ECMA_1"; |
michael@0 | 22 | startTest(); |
michael@0 | 23 | |
michael@0 | 24 | writeHeaderToLog( SECTION + " Date.prototype.setUTCMilliseconds(ms)"); |
michael@0 | 25 | |
michael@0 | 26 | addNewTestCase( 0, 0, "TDATE = new Date(0);(TDATE).setUTCMilliseconds(0);TDATE", |
michael@0 | 27 | UTCDateFromTime(SetUTCMilliseconds(0,0)), |
michael@0 | 28 | LocalDateFromTime(SetUTCMilliseconds(0,0)) ); |
michael@0 | 29 | addNewTestCase( 28800000,999, |
michael@0 | 30 | "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(999);TDATE", |
michael@0 | 31 | UTCDateFromTime(SetUTCMilliseconds(28800000,999)), |
michael@0 | 32 | LocalDateFromTime(SetUTCMilliseconds(28800000,999)) ); |
michael@0 | 33 | addNewTestCase( 28800000,-28800000, |
michael@0 | 34 | "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(-28800000);TDATE", |
michael@0 | 35 | UTCDateFromTime(SetUTCMilliseconds(28800000,-28800000)), |
michael@0 | 36 | LocalDateFromTime(SetUTCMilliseconds(28800000,-28800000)) ); |
michael@0 | 37 | addNewTestCase( 946684800000,1234567, |
michael@0 | 38 | "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(1234567);TDATE", |
michael@0 | 39 | UTCDateFromTime(SetUTCMilliseconds(946684800000,1234567)), |
michael@0 | 40 | LocalDateFromTime(SetUTCMilliseconds(946684800000,1234567)) ); |
michael@0 | 41 | addNewTestCase( 946684800000, 123456789, |
michael@0 | 42 | "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(123456789);TDATE", |
michael@0 | 43 | UTCDateFromTime(SetUTCMilliseconds(946684800000,123456789)), |
michael@0 | 44 | LocalDateFromTime(SetUTCMilliseconds(946684800000,123456789)) ); |
michael@0 | 45 | |
michael@0 | 46 | addNewTestCase( -2208988800000,123456789, |
michael@0 | 47 | "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", |
michael@0 | 48 | UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), |
michael@0 | 49 | LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); |
michael@0 | 50 | |
michael@0 | 51 | addNewTestCase( -2208988800000,123456, |
michael@0 | 52 | "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", |
michael@0 | 53 | UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), |
michael@0 | 54 | LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); |
michael@0 | 55 | |
michael@0 | 56 | addNewTestCase( -2208988800000,-123456, |
michael@0 | 57 | "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", |
michael@0 | 58 | UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), |
michael@0 | 59 | LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); |
michael@0 | 60 | |
michael@0 | 61 | addNewTestCase( 0,-999, |
michael@0 | 62 | "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", |
michael@0 | 63 | UTCDateFromTime(SetUTCMilliseconds(0,-999)), |
michael@0 | 64 | LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); |
michael@0 | 65 | |
michael@0 | 66 | test(); |
michael@0 | 67 | |
michael@0 | 68 | function addNewTestCase( initialTime, ms, DateString, UTCDate, LocalDate) { |
michael@0 | 69 | DateCase = new Date(initialTime); |
michael@0 | 70 | DateCase.setUTCMilliseconds(ms); |
michael@0 | 71 | |
michael@0 | 72 | new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); |
michael@0 | 73 | new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); |
michael@0 | 74 | |
michael@0 | 75 | new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); |
michael@0 | 76 | new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); |
michael@0 | 77 | new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); |
michael@0 | 78 | |
michael@0 | 79 | new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); |
michael@0 | 80 | new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); |
michael@0 | 81 | new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); |
michael@0 | 82 | new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); |
michael@0 | 83 | |
michael@0 | 84 | new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); |
michael@0 | 85 | new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); |
michael@0 | 86 | new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); |
michael@0 | 87 | |
michael@0 | 88 | new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); |
michael@0 | 89 | new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); |
michael@0 | 90 | new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); |
michael@0 | 91 | new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); |
michael@0 | 92 | |
michael@0 | 93 | DateCase.toString = Object.prototype.toString; |
michael@0 | 94 | |
michael@0 | 95 | new TestCase( SECTION, |
michael@0 | 96 | DateString+".toString=Object.prototype.toString;"+DateString+".toString()", |
michael@0 | 97 | "[object Date]", |
michael@0 | 98 | DateCase.toString() ); |
michael@0 | 99 | } |
michael@0 | 100 | function MyDate() { |
michael@0 | 101 | this.year = 0; |
michael@0 | 102 | this.month = 0; |
michael@0 | 103 | this.date = 0; |
michael@0 | 104 | this.hours = 0; |
michael@0 | 105 | this.minutes = 0; |
michael@0 | 106 | this.seconds = 0; |
michael@0 | 107 | this.ms = 0; |
michael@0 | 108 | } |
michael@0 | 109 | function LocalDateFromTime(t) { |
michael@0 | 110 | t = LocalTime(t); |
michael@0 | 111 | return ( MyDateFromTime(t) ); |
michael@0 | 112 | } |
michael@0 | 113 | function UTCDateFromTime(t) { |
michael@0 | 114 | return ( MyDateFromTime(t) ); |
michael@0 | 115 | } |
michael@0 | 116 | function MyDateFromTime( t ) { |
michael@0 | 117 | var d = new MyDate(); |
michael@0 | 118 | d.year = YearFromTime(t); |
michael@0 | 119 | d.month = MonthFromTime(t); |
michael@0 | 120 | d.date = DateFromTime(t); |
michael@0 | 121 | d.hours = HourFromTime(t); |
michael@0 | 122 | d.minutes = MinFromTime(t); |
michael@0 | 123 | d.seconds = SecFromTime(t); |
michael@0 | 124 | d.ms = msFromTime(t); |
michael@0 | 125 | |
michael@0 | 126 | d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); |
michael@0 | 127 | d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); |
michael@0 | 128 | d.day = WeekDay( d.value ); |
michael@0 | 129 | |
michael@0 | 130 | return (d); |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | function SetUTCMilliseconds( T, MS ) { |
michael@0 | 134 | T = Number( T ); |
michael@0 | 135 | TIME = MakeTime( HourFromTime(T), |
michael@0 | 136 | MinFromTime(T), |
michael@0 | 137 | SecFromTime(T), |
michael@0 | 138 | MS ); |
michael@0 | 139 | return( MakeDate( Day(T), TIME )); |
michael@0 | 140 | } |