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 | // |reftest| random-if(Android) |
michael@0 | 2 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | |
michael@0 | 8 | /** |
michael@0 | 9 | File Name: 15.9.5.28-1.js |
michael@0 | 10 | ECMA Section: 15.9.5.28 Date.prototype.setMinutes(min [, sec [, ms ]] ) |
michael@0 | 11 | Description: |
michael@0 | 12 | If sec is not specified, this behaves as if sec were specified with the |
michael@0 | 13 | value getSeconds ( ). |
michael@0 | 14 | |
michael@0 | 15 | If ms is not specified, this behaves as if ms were specified with the |
michael@0 | 16 | value getMilliseconds( ). |
michael@0 | 17 | |
michael@0 | 18 | 1. Let t be the result of LocalTime(this time value). |
michael@0 | 19 | 2. Call ToNumber(min). |
michael@0 | 20 | 3. If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec). |
michael@0 | 21 | 4. If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms). |
michael@0 | 22 | 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). |
michael@0 | 23 | 6. Compute UTC(MakeDate(Day(t), Result(5))). |
michael@0 | 24 | 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). |
michael@0 | 25 | 8. Return the value of the [[Value]] property of the this value. |
michael@0 | 26 | |
michael@0 | 27 | Author: christine@netscape.com |
michael@0 | 28 | Date: 12 november 1997 |
michael@0 | 29 | */ |
michael@0 | 30 | var SECTION = "15.9.5.28-1"; |
michael@0 | 31 | var VERSION = "ECMA_1"; |
michael@0 | 32 | startTest(); |
michael@0 | 33 | |
michael@0 | 34 | writeHeaderToLog( SECTION + " Date.prototype.setMinutes(sec [,ms] )"); |
michael@0 | 35 | |
michael@0 | 36 | addNewTestCase( 0, 0, void 0, void 0, |
michael@0 | 37 | "TDATE = new Date(0);(TDATE).setMinutes(0);TDATE", |
michael@0 | 38 | UTCDateFromTime(SetMinutes(0,0,0,0)), |
michael@0 | 39 | LocalDateFromTime(SetMinutes(0,0,0,0)) ); |
michael@0 | 40 | |
michael@0 | 41 | addNewTestCase( 28800000, 59, 59, void 0, |
michael@0 | 42 | "TDATE = new Date(28800000);(TDATE).setMinutes(59,59);TDATE", |
michael@0 | 43 | UTCDateFromTime(SetMinutes(28800000,59,59)), |
michael@0 | 44 | LocalDateFromTime(SetMinutes(28800000,59,59)) ); |
michael@0 | 45 | |
michael@0 | 46 | addNewTestCase( 28800000, 59, 59, 999, |
michael@0 | 47 | "TDATE = new Date(28800000);(TDATE).setMinutes(59,59,999);TDATE", |
michael@0 | 48 | UTCDateFromTime(SetMinutes(28800000,59,59,999)), |
michael@0 | 49 | LocalDateFromTime(SetMinutes(28800000,59,59,999)) ); |
michael@0 | 50 | |
michael@0 | 51 | addNewTestCase( 28800000, 59, void 0, void 0, |
michael@0 | 52 | "TDATE = new Date(28800000);(TDATE).setMinutes(59);TDATE", |
michael@0 | 53 | UTCDateFromTime(SetMinutes(28800000,59,0)), |
michael@0 | 54 | LocalDateFromTime(SetMinutes(28800000,59,0)) ); |
michael@0 | 55 | |
michael@0 | 56 | addNewTestCase( 28800000, -480, void 0, void 0, |
michael@0 | 57 | "TDATE = new Date(28800000);(TDATE).setMinutes(-480);TDATE", |
michael@0 | 58 | UTCDateFromTime(SetMinutes(28800000,-480)), |
michael@0 | 59 | LocalDateFromTime(SetMinutes(28800000,-480)) ); |
michael@0 | 60 | |
michael@0 | 61 | addNewTestCase( 946684800000, 1234567, void 0, void 0, |
michael@0 | 62 | "TDATE = new Date(946684800000);(TDATE).setMinutes(1234567);TDATE", |
michael@0 | 63 | UTCDateFromTime(SetMinutes(946684800000,1234567)), |
michael@0 | 64 | LocalDateFromTime(SetMinutes(946684800000,1234567)) ); |
michael@0 | 65 | |
michael@0 | 66 | addNewTestCase( -2208988800000,59, 59, void 0, |
michael@0 | 67 | "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59);TDATE", |
michael@0 | 68 | UTCDateFromTime(SetMinutes(-2208988800000,59,59)), |
michael@0 | 69 | LocalDateFromTime(SetMinutes(-2208988800000,59,59)) ); |
michael@0 | 70 | |
michael@0 | 71 | addNewTestCase( -2208988800000, 59, 59, 999, |
michael@0 | 72 | "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59,999);TDATE", |
michael@0 | 73 | UTCDateFromTime(SetMinutes(-2208988800000,59,59,999)), |
michael@0 | 74 | LocalDateFromTime(SetMinutes(-2208988800000,59,59,999)) ); |
michael@0 | 75 | |
michael@0 | 76 | test(); |
michael@0 | 77 | |
michael@0 | 78 | function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { |
michael@0 | 79 | DateCase = new Date( time ); |
michael@0 | 80 | |
michael@0 | 81 | if ( sec == void 0 ) { |
michael@0 | 82 | DateCase.setMinutes( min ); |
michael@0 | 83 | } else { |
michael@0 | 84 | if ( ms == void 0 ) { |
michael@0 | 85 | DateCase.setMinutes( min, sec ); |
michael@0 | 86 | } else { |
michael@0 | 87 | DateCase.setMinutes( min, sec, ms ); |
michael@0 | 88 | } |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); |
michael@0 | 92 | new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); |
michael@0 | 93 | |
michael@0 | 94 | new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); |
michael@0 | 95 | new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); |
michael@0 | 96 | new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); |
michael@0 | 97 | |
michael@0 | 98 | new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); |
michael@0 | 99 | new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); |
michael@0 | 100 | new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); |
michael@0 | 101 | new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); |
michael@0 | 102 | |
michael@0 | 103 | new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); |
michael@0 | 104 | new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); |
michael@0 | 105 | new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); |
michael@0 | 106 | |
michael@0 | 107 | new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); |
michael@0 | 108 | new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); |
michael@0 | 109 | new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); |
michael@0 | 110 | new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); |
michael@0 | 111 | |
michael@0 | 112 | DateCase.toString = Object.prototype.toString; |
michael@0 | 113 | |
michael@0 | 114 | new TestCase( SECTION, |
michael@0 | 115 | DateString+".toString=Object.prototype.toString;"+DateString+".toString()", |
michael@0 | 116 | "[object Date]", |
michael@0 | 117 | DateCase.toString() ); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | function MyDate() { |
michael@0 | 121 | this.year = 0; |
michael@0 | 122 | this.month = 0; |
michael@0 | 123 | this.date = 0; |
michael@0 | 124 | this.hours = 0; |
michael@0 | 125 | this.minutes = 0; |
michael@0 | 126 | this.seconds = 0; |
michael@0 | 127 | this.ms = 0; |
michael@0 | 128 | } |
michael@0 | 129 | function LocalDateFromTime(t) { |
michael@0 | 130 | t = LocalTime(t); |
michael@0 | 131 | return ( MyDateFromTime(t) ); |
michael@0 | 132 | } |
michael@0 | 133 | function UTCDateFromTime(t) { |
michael@0 | 134 | return ( MyDateFromTime(t) ); |
michael@0 | 135 | } |
michael@0 | 136 | function MyDateFromTime( t ) { |
michael@0 | 137 | var d = new MyDate(); |
michael@0 | 138 | d.year = YearFromTime(t); |
michael@0 | 139 | d.month = MonthFromTime(t); |
michael@0 | 140 | d.date = DateFromTime(t); |
michael@0 | 141 | d.hours = HourFromTime(t); |
michael@0 | 142 | d.minutes = MinFromTime(t); |
michael@0 | 143 | d.seconds = SecFromTime(t); |
michael@0 | 144 | d.ms = msFromTime(t); |
michael@0 | 145 | |
michael@0 | 146 | d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); |
michael@0 | 147 | d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); |
michael@0 | 148 | d.day = WeekDay( d.value ); |
michael@0 | 149 | |
michael@0 | 150 | return (d); |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | function SetMinutes( t, min, sec, ms ) { |
michael@0 | 154 | var TIME = LocalTime(t); |
michael@0 | 155 | var MIN = Number(min); |
michael@0 | 156 | var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); |
michael@0 | 157 | var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); |
michael@0 | 158 | var RESULT5 = MakeTime( HourFromTime( TIME ), |
michael@0 | 159 | MIN, |
michael@0 | 160 | SEC, |
michael@0 | 161 | MS ); |
michael@0 | 162 | return ( TimeClip(UTC( MakeDate(Day(TIME),RESULT5))) ); |
michael@0 | 163 | } |