js/src/tests/ecma/Date/15.9.4.2.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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 File Name: 15.9.4.2.js
michael@0 9 ECMA Section: 15.9.4.2 Date.parse()
michael@0 10 Description: The parse() function applies the to ToString() operator
michael@0 11 to its argument and interprets the resulting string as
michael@0 12 a date. It returns a number, the UTC time value
michael@0 13 corresponding to the date.
michael@0 14
michael@0 15 The string may be interpreted as a local time, a UTC
michael@0 16 time, or a time in some other time zone, depending on
michael@0 17 the contents of the string.
michael@0 18
michael@0 19 (need to test strings containing stuff with the time
michael@0 20 zone specified, and verify that parse() returns the
michael@0 21 correct GMT time)
michael@0 22
michael@0 23 so for any Date object x, all of these things should
michael@0 24 be equal:
michael@0 25
michael@0 26 value tested in function:
michael@0 27 x.valueOf() test_value()
michael@0 28 Date.parse(x.toString()) test_tostring()
michael@0 29 Date.parse(x.toGMTString()) test_togmt()
michael@0 30
michael@0 31 Date.parse(x.toLocaleString()) is not required to
michael@0 32 produce the same number value as the preceding three
michael@0 33 expressions. in general the value produced by
michael@0 34 Date.parse is implementation dependent when given any
michael@0 35 string value that could not be produced in that
michael@0 36 implementation by the toString or toGMTString method.
michael@0 37
michael@0 38 value tested in function:
michael@0 39 Date.parse( x.toLocaleString()) test_tolocale()
michael@0 40
michael@0 41 Author: christine@netscape.com
michael@0 42 Date: 10 july 1997
michael@0 43
michael@0 44 */
michael@0 45
michael@0 46 var VERSION = "ECMA_1";
michael@0 47 startTest();
michael@0 48 var SECTION = "15.9.4.2";
michael@0 49 var TITLE = "Date.parse()";
michael@0 50
michael@0 51 var TIME = 0;
michael@0 52 var UTC_YEAR = 1;
michael@0 53 var UTC_MONTH = 2;
michael@0 54 var UTC_DATE = 3;
michael@0 55 var UTC_DAY = 4;
michael@0 56 var UTC_HOURS = 5;
michael@0 57 var UTC_MINUTES = 6;
michael@0 58 var UTC_SECONDS = 7;
michael@0 59 var UTC_MS = 8;
michael@0 60
michael@0 61 var YEAR = 9;
michael@0 62 var MONTH = 10;
michael@0 63 var DATE = 11;
michael@0 64 var DAY = 12;
michael@0 65 var HOURS = 13;
michael@0 66 var MINUTES = 14;
michael@0 67 var SECONDS = 15;
michael@0 68 var MS = 16;
michael@0 69 var TYPEOF = "object";
michael@0 70
michael@0 71 // for TCMS, the gTestcases array must be global.
michael@0 72 writeHeaderToLog("15.9.4.2 Date.parse()" );
michael@0 73
michael@0 74 // Dates around 1970
michael@0 75
michael@0 76 addNewTestCase( new Date(0),
michael@0 77 "new Date(0)",
michael@0 78 [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
michael@0 79
michael@0 80 addNewTestCase( new Date(-1),
michael@0 81 "new Date(-1)",
michael@0 82 [-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] );
michael@0 83 addNewTestCase( new Date(28799999),
michael@0 84 "new Date(28799999)",
michael@0 85 [28799999,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] );
michael@0 86 addNewTestCase( new Date(28800000),
michael@0 87 "new Date(28800000)",
michael@0 88 [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
michael@0 89
michael@0 90 // Dates around 2000
michael@0 91
michael@0 92 addNewTestCase( new Date(946684799999),
michael@0 93 "new Date(946684799999)",
michael@0 94 [946684799999,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] );
michael@0 95 addNewTestCase( new Date(946713599999),
michael@0 96 "new Date(946713599999)",
michael@0 97 [946713599999,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] );
michael@0 98 addNewTestCase( new Date(946684800000),
michael@0 99 "new Date(946684800000)",
michael@0 100 [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
michael@0 101 addNewTestCase( new Date(946713600000),
michael@0 102 "new Date(946713600000)",
michael@0 103 [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
michael@0 104
michael@0 105 // Dates around 1900
michael@0 106
michael@0 107 addNewTestCase( new Date(-2208988800000),
michael@0 108 "new Date(-2208988800000)",
michael@0 109 [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
michael@0 110
michael@0 111 addNewTestCase( new Date(-2208988800001),
michael@0 112 "new Date(-2208988800001)",
michael@0 113 [-2208988800001,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
michael@0 114
michael@0 115 addNewTestCase( new Date(-2208960000001),
michael@0 116 "new Date(-2208960000001)",
michael@0 117 [-2208960000001,1900,0,1,1,7,59,59,0,1899,11,31,0,23,59,59,999] );
michael@0 118 addNewTestCase( new Date(-2208960000000),
michael@0 119 "new Date(-2208960000000)",
michael@0 120 [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
michael@0 121 addNewTestCase( new Date(-2208959999999),
michael@0 122 "new Date(-2208959999999)",
michael@0 123 [-2208959999999,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
michael@0 124
michael@0 125 // Dates around Feb 29, 2000
michael@0 126
michael@0 127 var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour;
michael@0 128
michael@0 129 addNewTestCase( new Date(UTC_FEB_29_2000),
michael@0 130 "new Date(" + UTC_FEB_29_2000 +")",
michael@0 131 [UTC_FEB_29_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
michael@0 132 addNewTestCase( new Date(PST_FEB_29_2000),
michael@0 133 "new Date(" + PST_FEB_29_2000 +")",
michael@0 134 [PST_FEB_29_2000,2000,0,1,6,8.0,0,0,2000,0,1,6,0,0,0,0]);
michael@0 135
michael@0 136 // Dates around Jan 1 2005
michael@0 137
michael@0 138 var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour;
michael@0 139
michael@0 140 addNewTestCase( new Date(UTC_JAN_1_2005),
michael@0 141 "new Date("+ UTC_JAN_1_2005 +")",
michael@0 142 [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
michael@0 143 addNewTestCase( new Date(PST_JAN_1_2005),
michael@0 144 "new Date("+ PST_JAN_1_2005 +")",
michael@0 145 [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
michael@0 146
michael@0 147
michael@0 148 test();
michael@0 149
michael@0 150 function addNewTestCase( DateCase, DateString, ResultArray ) {
michael@0 151 DateCase = DateCase;
michael@0 152
michael@0 153 new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
michael@0 154 new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
michael@0 155 new TestCase( SECTION, "Date.parse(" + DateCase.toString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toString()) );
michael@0 156 new TestCase( SECTION, "Date.parse(" + DateCase.toGMTString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toGMTString()) );
michael@0 157 }

mercurial