js/src/tests/ecma/Date/15.9.5.33-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.33-1.js
     9    ECMA Section:       15.9.5.33 Date.prototype.setUTCDate(date)
    10    Description:
    11    1.  Let t be this time value.
    12    2.  Call ToNumber(date).
    13    3.  Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)).
    14    4.  Compute MakeDate(Result(3), TimeWithinDay(t)).
    15    5.  Set the [[Value]] property of the this value to TimeClip(Result(4)).
    16    6.  Return the value of the [[Value]] property of the this value.
    18    Author:             christine@netscape.com
    19    Date:               12 november 1997
    20 */
    21 var SECTION = "15.9.5.33-1";
    22 var VERSION = "ECMA_1";
    23 startTest();
    25 writeHeaderToLog( SECTION + " Date.prototype.setUTCDate(date) ");
    27 addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(31);TDATE",
    28 		UTCDateFromTime(SetUTCDate(0,31)),
    29 		LocalDateFromTime(SetUTCDate(0,31)) );
    31 addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(1);TDATE",
    32 		UTCDateFromTime(SetUTCDate(0,1)),
    33 		LocalDateFromTime(SetUTCDate(0,1)) );
    35 addNewTestCase( "TDATE = new Date(86400000);(TDATE).setUTCDate(1);TDATE",
    36 		UTCDateFromTime(SetUTCDate(86400000,1)),
    37 		LocalDateFromTime(SetUTCDate(86400000,1)) );
    39 test();
    41 function addNewTestCase( DateString, UTCDate, LocalDate) {
    42   DateCase = eval( DateString );
    45   new TestCase( SECTION, DateString+".getTime()",             UTCDate.value,       DateCase.getTime() );
    46   new TestCase( SECTION, DateString+".valueOf()",             UTCDate.value,       DateCase.valueOf() );
    48   new TestCase( SECTION, DateString+".getUTCFullYear()",      UTCDate.year,    DateCase.getUTCFullYear() );
    49   new TestCase( SECTION, DateString+".getUTCMonth()",         UTCDate.month,  DateCase.getUTCMonth() );
    50   new TestCase( SECTION, DateString+".getUTCDate()",          UTCDate.date,   DateCase.getUTCDate() );
    51   new TestCase( SECTION, DateString+".getUTCDay()",           UTCDate.day,    DateCase.getUTCDay() );
    52   new TestCase( SECTION, DateString+".getUTCHours()",         UTCDate.hours,  DateCase.getUTCHours() );
    53   new TestCase( SECTION, DateString+".getUTCMinutes()",       UTCDate.minutes,DateCase.getUTCMinutes() );
    54   new TestCase( SECTION, DateString+".getUTCSeconds()",       UTCDate.seconds,DateCase.getUTCSeconds() );
    55   new TestCase( SECTION, DateString+".getUTCMilliseconds()",  UTCDate.ms,     DateCase.getUTCMilliseconds() );
    57   new TestCase( SECTION, DateString+".getFullYear()",         LocalDate.year,       DateCase.getFullYear() );
    58   new TestCase( SECTION, DateString+".getMonth()",            LocalDate.month,      DateCase.getMonth() );
    59   new TestCase( SECTION, DateString+".getDate()",             LocalDate.date,       DateCase.getDate() );
    60   new TestCase( SECTION, DateString+".getDay()",              LocalDate.day,        DateCase.getDay() );
    61   new TestCase( SECTION, DateString+".getHours()",            LocalDate.hours,      DateCase.getHours() );
    62   new TestCase( SECTION, DateString+".getMinutes()",          LocalDate.minutes,    DateCase.getMinutes() );
    63   new TestCase( SECTION, DateString+".getSeconds()",          LocalDate.seconds,    DateCase.getSeconds() );
    64   new TestCase( SECTION, DateString+".getMilliseconds()",     LocalDate.ms,         DateCase.getMilliseconds() );
    66   DateCase.toString = Object.prototype.toString;
    68   new TestCase( SECTION,
    69 		DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
    70 		"[object Date]",
    71 		DateCase.toString() );
    72 }
    73 function MyDate() {
    74   this.year = 0;
    75   this.month = 0;
    76   this.date = 0;
    77   this.hours = 0;
    78   this.minutes = 0;
    79   this.seconds = 0;
    80   this.ms = 0;
    81 }
    82 function LocalDateFromTime(t) {
    83   t = LocalTime(t);
    84   return ( MyDateFromTime(t) );
    85 }
    86 function UTCDateFromTime(t) {
    87   return ( MyDateFromTime(t) );
    88 }
    89 function MyDateFromTime( t ) {
    90   var d = new MyDate();
    91   d.year = YearFromTime(t);
    92   d.month = MonthFromTime(t);
    93   d.date = DateFromTime(t);
    94   d.hours = HourFromTime(t);
    95   d.minutes = MinFromTime(t);
    96   d.seconds = SecFromTime(t);
    97   d.ms = msFromTime(t);
    99   d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
   100   d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
   101   d.day = WeekDay( d.value );
   103   return (d);
   104 }
   105 function SetUTCDate( t, date ) {
   106   var T       = t;
   107   var DATE    = Number( date );
   108   var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE );
   109   return ( TimeClip(MakeDate(RESULT3, TimeWithinDay(t))) );
   110 }

mercurial