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