js/src/tests/ecma/Date/15.9.5.35-1.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 // |reftest| random-if(Android)
michael@0 2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7
michael@0 8 /**
michael@0 9 File Name: 15.9.5.35-1.js
michael@0 10 ECMA Section: 15.9.5.35 Date.prototype.setUTCMonth(mon [,date])
michael@0 11 Description:
michael@0 12 Author: christine@netscape.com
michael@0 13 Date: 12 november 1997
michael@0 14 */
michael@0 15 var SECTION = "15.9.5.35-1";
michael@0 16 var VERSION = "ECMA_1";
michael@0 17 startTest();
michael@0 18
michael@0 19 writeHeaderToLog( SECTION + " Date.prototype.setUTCMonth(mon [,date] ) ");
michael@0 20 addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(0);TDATE",
michael@0 21 UTCDateFromTime(SetUTCMonth(0,0)),
michael@0 22 LocalDateFromTime(SetUTCMonth(0,0)) );
michael@0 23
michael@0 24 addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(11);TDATE",
michael@0 25 UTCDateFromTime(SetUTCMonth(0,11)),
michael@0 26 LocalDateFromTime(SetUTCMonth(0,11)) );
michael@0 27
michael@0 28 addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(5,4);TDATE",
michael@0 29 UTCDateFromTime(SetUTCMonth(0,5,4)),
michael@0 30 LocalDateFromTime(SetUTCMonth(0,5,4)) );
michael@0 31
michael@0 32 test();
michael@0 33
michael@0 34 function addNewTestCase( DateString, UTCDate, LocalDate) {
michael@0 35 DateCase = eval( DateString );
michael@0 36
michael@0 37 new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() );
michael@0 38 new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() );
michael@0 39
michael@0 40 new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() );
michael@0 41 new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() );
michael@0 42 new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() );
michael@0 43 new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() );
michael@0 44 new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() );
michael@0 45 new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() );
michael@0 46 new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() );
michael@0 47 new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() );
michael@0 48
michael@0 49 new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() );
michael@0 50 new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() );
michael@0 51 new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() );
michael@0 52 new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() );
michael@0 53 new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() );
michael@0 54 new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() );
michael@0 55 new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() );
michael@0 56 new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() );
michael@0 57
michael@0 58 DateCase.toString = Object.prototype.toString;
michael@0 59
michael@0 60 new TestCase( SECTION,
michael@0 61 DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
michael@0 62 "[object Date]",
michael@0 63 DateCase.toString() );
michael@0 64 }
michael@0 65 function MyDate() {
michael@0 66 this.year = 0;
michael@0 67 this.month = 0;
michael@0 68 this.date = 0;
michael@0 69 this.hours = 0;
michael@0 70 this.minutes = 0;
michael@0 71 this.seconds = 0;
michael@0 72 this.ms = 0;
michael@0 73 }
michael@0 74 function LocalDateFromTime(t) {
michael@0 75 t = LocalTime(t);
michael@0 76 return ( MyDateFromTime(t) );
michael@0 77 }
michael@0 78 function UTCDateFromTime(t) {
michael@0 79 return ( MyDateFromTime(t) );
michael@0 80 }
michael@0 81 function MyDateFromTime( t ) {
michael@0 82 var d = new MyDate();
michael@0 83 d.year = YearFromTime(t);
michael@0 84 d.month = MonthFromTime(t);
michael@0 85 d.date = DateFromTime(t);
michael@0 86 d.hours = HourFromTime(t);
michael@0 87 d.minutes = MinFromTime(t);
michael@0 88 d.seconds = SecFromTime(t);
michael@0 89 d.ms = msFromTime(t);
michael@0 90
michael@0 91 d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
michael@0 92 d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
michael@0 93 d.day = WeekDay( d.value );
michael@0 94
michael@0 95 return (d);
michael@0 96 }
michael@0 97 function SetUTCMonth( t, month, date ) {
michael@0 98 var T = t;
michael@0 99 var MONTH = Number( month );
michael@0 100 var DATE = ( date == void 0) ? DateFromTime(T) : Number( date );
michael@0 101
michael@0 102 var RESULT4 = MakeDay(YearFromTime(T), MONTH, DATE );
michael@0 103 var RESULT5 = MakeDate( RESULT4, TimeWithinDay(T));
michael@0 104
michael@0 105 return ( TimeClip(RESULT5) );
michael@0 106 }

mercurial