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.

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

mercurial