js/src/tests/ecma/Date/15.9.5.5.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.5.js
     9    ECMA Section:       15.9.5.5
    10    Description:        Date.prototype.getYear
    12    This function is specified here for backwards compatibility only. The
    13    function getFullYear is much to be preferred for nearly all purposes,
    14    because it avoids the "year 2000 problem."
    16    1.  Let t be this time value.
    17    2.  If t is NaN, return NaN.
    18    3.  Return YearFromTime(LocalTime(t)) 1900.
    20    Author:             christine@netscape.com
    21    Date:               12 november 1997
    22 */
    24 var SECTION = "15.9.5.5";
    25 var VERSION = "ECMA_1";
    26 startTest();
    27 var TITLE   = "Date.prototype.getYear()";
    29 writeHeaderToLog( SECTION + " "+ TITLE);
    31 addTestCase( TIME_NOW );
    32 addTestCase( TIME_0000 );
    33 addTestCase( TIME_1970 );
    34 addTestCase( TIME_1900 );
    35 addTestCase( TIME_2000 );
    36 addTestCase( UTC_FEB_29_2000 );
    38 new TestCase( SECTION,
    39 	      "(new Date(NaN)).getYear()",
    40 	      NaN,
    41 	      (new Date(NaN)).getYear() );
    43 new TestCase( SECTION,
    44 	      "Date.prototype.getYear.length",
    45 	      0,
    46 	      Date.prototype.getYear.length );
    48 test();
    50 function addTestCase( t ) {
    51   new TestCase( SECTION,
    52 		"(new Date("+t+")).getYear()",
    53 		GetYear(YearFromTime(LocalTime(t))),
    54 		(new Date(t)).getYear() );
    56   new TestCase( SECTION,
    57 		"(new Date("+(t+1)+")).getYear()",
    58 		GetYear(YearFromTime(LocalTime(t+1))),
    59 		(new Date(t+1)).getYear() );
    61   new TestCase( SECTION,
    62 		"(new Date("+(t-1)+")).getYear()",
    63 		GetYear(YearFromTime(LocalTime(t-1))),
    64 		(new Date(t-1)).getYear() );
    66   new TestCase( SECTION,
    67 		"(new Date("+(t-TZ_ADJUST)+")).getYear()",
    68 		GetYear(YearFromTime(LocalTime(t-TZ_ADJUST))),
    69 		(new Date(t-TZ_ADJUST)).getYear() );
    71   new TestCase( SECTION,
    72 		"(new Date("+(t+TZ_ADJUST)+")).getYear()",
    73 		GetYear(YearFromTime(LocalTime(t+TZ_ADJUST))),
    74 		(new Date(t+TZ_ADJUST)).getYear() );
    75 }
    76 function GetYear( year ) {
    77   return year - 1900;
    78 }

mercurial