Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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.3.8.js
9 ECMA Section: 15.9.3.8 The Date Constructor
10 new Date( value )
11 Description: The [[Prototype]] property of the newly constructed
12 object is set to the original Date prototype object,
13 the one that is the initial valiue of Date.prototype.
15 The [[Class]] property of the newly constructed object is
16 set to "Date".
18 The [[Value]] property of the newly constructed object is
19 set as follows:
21 1. Call ToPrimitive(value)
22 2. If Type( Result(1) ) is String, then go to step 5.
23 3. Let V be ToNumber( Result(1) ).
24 4. Set the [[Value]] property of the newly constructed
25 object to TimeClip(V) and return.
26 5. Parse Result(1) as a date, in exactly the same manner
27 as for the parse method. Let V be the time value for
28 this date.
29 6. Go to step 4.
31 Author: christine@netscape.com
32 Date: 28 october 1997
33 Version: 9706
35 */
37 var VERSION = "ECMA_1";
38 startTest();
39 var SECTION = "15.9.3.8";
40 var TYPEOF = "object";
42 var TIME = 0;
43 var UTC_YEAR = 1;
44 var UTC_MONTH = 2;
45 var UTC_DATE = 3;
46 var UTC_DAY = 4;
47 var UTC_HOURS = 5;
48 var UTC_MINUTES = 6;
49 var UTC_SECONDS = 7;
50 var UTC_MS = 8;
52 var YEAR = 9;
53 var MONTH = 10;
54 var DATE = 11;
55 var DAY = 12;
56 var HOURS = 13;
57 var MINUTES = 14;
58 var SECONDS = 15;
59 var MS = 16;
62 // for TCMS, the gTestcases array must be global.
63 var gTc= 0;
64 var TITLE = "Date constructor: new Date( value )";
65 var SECTION = "15.9.3.8";
66 var VERSION = "ECMA_1";
67 startTest();
69 writeHeaderToLog( SECTION +" " + TITLE );
71 // all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
72 var TZ_ADJUST = -TZ_PST * msPerHour;
74 // Dates around Feb 29, 2000
76 var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST;
78 addNewTestCase( new Date(UTC_FEB_29_2000),
79 "new Date("+UTC_FEB_29_2000+")",
80 [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
82 addNewTestCase( new Date(PST_FEB_29_2000),
83 "new Date("+PST_FEB_29_2000+")",
84 [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
86 addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ),
87 "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")",
88 [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
90 addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ),
91 "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")",
92 [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
95 addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ),
96 "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")",
97 [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
99 addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ),
100 "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")",
101 [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
103 test();
105 function addNewTestCase( DateCase, DateString, ResultArray ) {
106 //adjust hard-coded ResultArray for tester's timezone instead of PST
107 adjustResultArray(ResultArray, 'msMode');
109 new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
110 new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
111 new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
112 new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
113 new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
114 new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
115 new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
116 new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
117 new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
118 new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
119 new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
120 new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
121 new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
122 new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
123 new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
124 new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
125 new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
126 new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
127 }