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.5.24-1.js
9 ECMA Section: 15.9.5.24 Date.prototype.setTime(time)
10 Description:
11 1. If the this value is not a Date object, generate a runtime error.
12 2. Call ToNumber(time).
13 3. Call TimeClip(Result(1)).
14 4. Set the [[Value]] property of the this value to Result(2).
15 5. Return the value of the [[Value]] property of the this value.
16 Author: christine@netscape.com
17 Date: 12 november 1997
19 */
20 var TITLE = "Date.prototype.setTime"
21 var SECTION = "15.9.5.24-1";
22 var VERSION = "ECMA_1";
23 startTest();
25 writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)");
28 addTestCase( 0, 946684800000 );
30 test();
32 function addTestCase( startms, newms ) {
34 var DateCase = new Date( startms );
35 DateCase.setMilliseconds( newms );
36 var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date";
37 var localms = UTC( Number(newms) + LocalTime( Number(startms) ) );
38 var UTCDate = UTCDateFromTime( localms );
39 var LocalDate = LocalDateFromTime( localms );
41 new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() );
42 new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() );
44 new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() );
45 new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() );
46 new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() );
48 new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() );
49 new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() );
50 new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() );
51 new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() );
53 new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() );
54 new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() );
55 new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() );
57 new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() );
58 new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() );
59 new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() );
60 new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() );
62 DateCase.toString = Object.prototype.toString;
64 new TestCase( SECTION,
65 DateString+".toString=Object.prototype.toString;"+DateString+".toString()",
66 "[object Date]",
67 DateCase.toString() );
68 }
70 function MyDate() {
71 this.year = 0;
72 this.month = 0;
73 this.date = 0;
74 this.hours = 0;
75 this.minutes = 0;
76 this.seconds = 0;
77 this.ms = 0;
78 }
79 function LocalDateFromTime(t) {
80 t = LocalTime(t);
81 return ( MyDateFromTime(t) );
82 }
83 function UTCDateFromTime(t) {
84 return ( MyDateFromTime(t) );
85 }
86 function MyDateFromTime( t ) {
87 var d = new MyDate();
88 d.year = YearFromTime(t);
89 d.month = MonthFromTime(t);
90 d.date = DateFromTime(t);
91 d.hours = HourFromTime(t);
92 d.minutes = MinFromTime(t);
93 d.seconds = SecFromTime(t);
94 d.ms = msFromTime(t);
96 d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
97 d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) );
98 d.day = WeekDay( d.value );
100 return (d);
101 }