js/src/tests/ecma/Date/15.9.5.36-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.

     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 /**
     8    File Name:          15.9.5.36-1.js
     9    ECMA Section:       15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] )
    10    Description:
    12    If mon is not specified, this behaves as if mon were specified with the
    13    value getMonth( ). If date is not specified, this behaves as if date were
    14    specified with the value getDate( ).
    16    1.   Let t be the result of LocalTime(this time value); but if this time
    17    value is NaN, let t be +0.
    18    2.   Call ToNumber(year).
    19    3.   If mon is not specified, compute MonthFromTime(t); otherwise, call
    20    ToNumber(mon).
    21    4.   If date is not specified, compute DateFromTime(t); otherwise, call
    22    ToNumber(date).
    23    5.   Compute MakeDay(Result(2), Result(3), Result(4)).
    24    6.   Compute UTC(MakeDate(Result(5), TimeWithinDay(t))).
    25    7.   Set the [[Value]] property of the this value to TimeClip(Result(6)).
    26    8.   Return the value of the [[Value]] property of the this value.
    28    Author:             christine@netscape.com
    29    Date:               12 november 1997
    31    Added test cases for Year 2000 Compatilibity Testing.
    33 */
    34 var SECTION = "15.9.5.36-1";
    35 var VERSION = "ECMA_1";
    36 startTest();
    38 writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )");
    41 // 1969
    43 addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969);TDATE",
    44 		UTCDateFromTime(SetFullYear(0,1969)),
    45 		LocalDateFromTime(SetFullYear(0,1969)) );
    47 addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11);TDATE",
    48 		UTCDateFromTime(SetFullYear(0,1969,11)),
    49 		LocalDateFromTime(SetFullYear(0,1969,11)) );
    51 addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11,31);TDATE",
    52 		UTCDateFromTime(SetFullYear(0,1969,11,31)),
    53 		LocalDateFromTime(SetFullYear(0,1969,11,31)) );
    55 test();
    57 function addNewTestCase( DateString, UTCDate, LocalDate) {
    58   DateCase = eval( DateString );
    60   new TestCase( SECTION, DateString+".getTime()",             UTCDate.value,       DateCase.getTime() );
    61   new TestCase( SECTION, DateString+".valueOf()",             UTCDate.value,       DateCase.valueOf() );
    63   new TestCase( SECTION, DateString+".getUTCFullYear()",      UTCDate.year,    DateCase.getUTCFullYear() );
    64   new TestCase( SECTION, DateString+".getUTCMonth()",         UTCDate.month,  DateCase.getUTCMonth() );
    65   new TestCase( SECTION, DateString+".getUTCDate()",          UTCDate.date,   DateCase.getUTCDate() );
    66   new TestCase( SECTION, DateString+".getUTCDay()",           UTCDate.day,    DateCase.getUTCDay() );
    67   new TestCase( SECTION, DateString+".getUTCHours()",         UTCDate.hours,  DateCase.getUTCHours() );
    68   new TestCase( SECTION, DateString+".getUTCMinutes()",       UTCDate.minutes,DateCase.getUTCMinutes() );
    69   new TestCase( SECTION, DateString+".getUTCSeconds()",       UTCDate.seconds,DateCase.getUTCSeconds() );
    70   new TestCase( SECTION, DateString+".getUTCMilliseconds()",  UTCDate.ms,     DateCase.getUTCMilliseconds() );
    72   new TestCase( SECTION, DateString+".getFullYear()",         LocalDate.year,       DateCase.getFullYear() );
    73   new TestCase( SECTION, DateString+".getMonth()",            LocalDate.month,      DateCase.getMonth() );
    74   new TestCase( SECTION, DateString+".getDate()",             LocalDate.date,       DateCase.getDate() );
    75   new TestCase( SECTION, DateString+".getDay()",              LocalDate.day,        DateCase.getDay() );
    76   new TestCase( SECTION, DateString+".getHours()",            LocalDate.hours,      DateCase.getHours() );
    77   new TestCase( SECTION, DateString+".getMinutes()",          LocalDate.minutes,    DateCase.getMinutes() );
    78   new TestCase( SECTION, DateString+".getSeconds()",          LocalDate.seconds,    DateCase.getSeconds() );
    79   new TestCase( SECTION, DateString+".getMilliseconds()",     LocalDate.ms,         DateCase.getMilliseconds() );
    81   DateCase.toString = Object.prototype.toString;
    83   new TestCase( SECTION,
    84 		DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
    85 		"[object Date]",
    86 		DateCase.toString() );
    87 }
    89 function MyDate() {
    90   this.year = 0;
    91   this.month = 0;
    92   this.date = 0;
    93   this.hours = 0;
    94   this.minutes = 0;
    95   this.seconds = 0;
    96   this.ms = 0;
    97 }
    98 function LocalDateFromTime(t) {
    99   t = LocalTime(t);
   100   return ( MyDateFromTime(t) );
   101 }
   102 function UTCDateFromTime(t) {
   103   return ( MyDateFromTime(t) );
   104 }
   105 function MyDateFromTime( t ) {
   106   var d = new MyDate();
   107   d.year = YearFromTime(t);
   108   d.month = MonthFromTime(t);
   109   d.date = DateFromTime(t);
   110   d.hours = HourFromTime(t);
   111   d.minutes = MinFromTime(t);
   112   d.seconds = SecFromTime(t);
   113   d.ms = msFromTime(t);
   115   d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
   116   d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
   117   d.day = WeekDay( d.value );
   119   return (d);
   120 }
   121 function SetFullYear( t, year, mon, date ) {
   122   var T = ( isNaN(t) ) ? 0 : LocalTime(t) ;
   123   var YEAR = Number( year );
   124   var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon );
   125   var DATE = ( date == void 0 ) ? DateFromTime(T)  : Number( date );
   127   var DAY = MakeDay( YEAR, MONTH, DATE );
   128   var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T)));
   130   return ( TimeClip(UTC_DATE) );
   131 }

mercurial