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 /** File Name: 15.9.5.26-1.js
8 ECMA Section: 15.9.5.26 Date.prototype.setSeconds(sec [,ms])
9 Description:
11 If ms is not specified, this behaves as if ms were specified with the
12 value getMilliseconds( ).
14 1. Let t be the result of LocalTime(this time value).
15 2. Call ToNumber(sec).
16 3. If ms is not specified, compute msFromTime(t); otherwise, call
17 ToNumber(ms).
18 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2),
19 Result(3)).
20 5. Compute UTC(MakeDate(Day(t), Result(4))).
21 6. Set the [[Value]] property of the this value to TimeClip(Result(5)).
22 7. Return the value of the [[Value]] property of the this value.
24 Author: christine@netscape.com
25 Date: 12 november 1997
26 */
27 var SECTION = "15.9.5.26-1";
28 var VERSION = "ECMA_1";
29 startTest();
31 writeHeaderToLog( SECTION + " Date.prototype.setSeconds(sec [,ms] )");
33 addNewTestCase( 0, 0, 0,
34 "TDATE = new Date(0);(TDATE).setSeconds(0,0);TDATE",
35 UTCDateFromTime(SetSeconds(0,0,0)),
36 LocalDateFromTime(SetSeconds(0,0,0)) );
38 addNewTestCase( 28800000,59,999,
39 "TDATE = new Date(28800000);(TDATE).setSeconds(59,999);TDATE",
40 UTCDateFromTime(SetSeconds(28800000,59,999)),
41 LocalDateFromTime(SetSeconds(28800000,59,999)) );
43 addNewTestCase( 28800000,999,999,
44 "TDATE = new Date(28800000);(TDATE).setSeconds(999,999);TDATE",
45 UTCDateFromTime(SetSeconds(28800000,999,999)),
46 LocalDateFromTime(SetSeconds(28800000,999,999)) );
48 addNewTestCase( 28800000,999, void 0,
49 "TDATE = new Date(28800000);(TDATE).setSeconds(999);TDATE",
50 UTCDateFromTime(SetSeconds(28800000,999,0)),
51 LocalDateFromTime(SetSeconds(28800000,999,0)) );
53 addNewTestCase( 28800000,-28800, void 0,
54 "TDATE = new Date(28800000);(TDATE).setSeconds(-28800);TDATE",
55 UTCDateFromTime(SetSeconds(28800000,-28800)),
56 LocalDateFromTime(SetSeconds(28800000,-28800)) );
58 addNewTestCase( 946684800000,1234567,void 0,
59 "TDATE = new Date(946684800000);(TDATE).setSeconds(1234567);TDATE",
60 UTCDateFromTime(SetSeconds(946684800000,1234567)),
61 LocalDateFromTime(SetSeconds(946684800000,1234567)) );
63 addNewTestCase( -2208988800000,59,999,
64 "TDATE = new Date(-2208988800000);(TDATE).setSeconds(59,999);TDATE",
65 UTCDateFromTime(SetSeconds(-2208988800000,59,999)),
66 LocalDateFromTime(SetSeconds(-2208988800000,59,999)) );
68 test();
70 function addNewTestCase( startTime, sec, ms, DateString,UTCDate, LocalDate) {
71 DateCase = new Date( startTime );
72 if ( ms != void 0 ) {
73 DateCase.setSeconds( sec, ms );
74 } else {
75 DateCase.setSeconds( sec );
76 }
78 new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() );
79 new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() );
81 new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() );
82 new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() );
83 new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() );
85 new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() );
86 new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() );
87 new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() );
88 new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() );
90 new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() );
91 new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() );
92 new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() );
94 new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() );
95 new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() );
96 new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() );
97 new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() );
99 DateCase.toString = Object.prototype.toString;
101 new TestCase( SECTION,
102 DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
103 "[object Date]",
104 DateCase.toString() );
105 }
107 function MyDate() {
108 this.year = 0;
109 this.month = 0;
110 this.date = 0;
111 this.hours = 0;
112 this.minutes = 0;
113 this.seconds = 0;
114 this.ms = 0;
115 }
116 function LocalDateFromTime(t) {
117 t = LocalTime(t);
118 return ( MyDateFromTime(t) );
119 }
120 function UTCDateFromTime(t) {
121 return ( MyDateFromTime(t) );
122 }
123 function MyDateFromTime( t ) {
124 var d = new MyDate();
125 d.year = YearFromTime(t);
126 d.month = MonthFromTime(t);
127 d.date = DateFromTime(t);
128 d.hours = HourFromTime(t);
129 d.minutes = MinFromTime(t);
130 d.seconds = SecFromTime(t);
131 d.ms = msFromTime(t);
133 d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
134 d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
135 d.day = WeekDay( d.value );
137 return (d);
138 }
139 function SetSeconds( t, s, m ) {
140 var MS = ( m == void 0 ) ? msFromTime(t) : Number( m );
141 var TIME = LocalTime( t );
142 var SEC = Number(s);
143 var RESULT4 = MakeTime( HourFromTime( TIME ),
144 MinFromTime( TIME ),
145 SEC,
146 MS );
147 var UTC_TIME = UTC(MakeDate(Day(TIME), RESULT4));
148 return ( TimeClip(UTC_TIME) );
149 }