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 | var BUGNUMBER = 363578; |
michael@0 | 8 | var summary = '15.9.4.3 - Date.UTC edge-case arguments.'; |
michael@0 | 9 | var actual = ''; |
michael@0 | 10 | var expect = ''; |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | //----------------------------------------------------------------------------- |
michael@0 | 14 | test(); |
michael@0 | 15 | //----------------------------------------------------------------------------- |
michael@0 | 16 | |
michael@0 | 17 | function test() |
michael@0 | 18 | { |
michael@0 | 19 | enterFunc ('test'); |
michael@0 | 20 | printBugNumber(BUGNUMBER); |
michael@0 | 21 | printStatus (summary); |
michael@0 | 22 | |
michael@0 | 23 | // |
michael@0 | 24 | |
michael@0 | 25 | expect = 31; |
michael@0 | 26 | actual = (new Date(Date.UTC(2006, 0, 0)).getUTCDate()); |
michael@0 | 27 | reportCompare(expect, actual, summary + ': date 0'); |
michael@0 | 28 | |
michael@0 | 29 | expect = 0; |
michael@0 | 30 | actual = (new Date(Date.UTC(2006, 0, 0, 0)).getUTCHours()); |
michael@0 | 31 | reportCompare(expect, actual, summary + ': hours 0'); |
michael@0 | 32 | |
michael@0 | 33 | expect = 0; |
michael@0 | 34 | actual = (new Date(Date.UTC(2006, 0, 0, 0, 0)).getUTCMinutes()); |
michael@0 | 35 | reportCompare(expect, actual, summary + ': minutes 0'); |
michael@0 | 36 | |
michael@0 | 37 | expect = 0; |
michael@0 | 38 | actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, 0)).getUTCSeconds()); |
michael@0 | 39 | reportCompare(expect, actual, summary + ': seconds 0'); |
michael@0 | 40 | |
michael@0 | 41 | expect = 0; |
michael@0 | 42 | actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, 0, 0)).getUTCMilliseconds()); |
michael@0 | 43 | reportCompare(expect, actual, summary + ': milliseconds 0'); |
michael@0 | 44 | |
michael@0 | 45 | // |
michael@0 | 46 | |
michael@0 | 47 | expect = 30; |
michael@0 | 48 | actual = (new Date(Date.UTC(2006, 0, -1)).getUTCDate()); |
michael@0 | 49 | reportCompare(expect, actual, summary + ': date -1'); |
michael@0 | 50 | |
michael@0 | 51 | expect = 23; |
michael@0 | 52 | actual = (new Date(Date.UTC(2006, 0, 0, -1)).getUTCHours()); |
michael@0 | 53 | reportCompare(expect, actual, summary + ': hours -1'); |
michael@0 | 54 | |
michael@0 | 55 | expect = 59; |
michael@0 | 56 | actual = (new Date(Date.UTC(2006, 0, 0, 0, -1)).getUTCMinutes()); |
michael@0 | 57 | reportCompare(expect, actual, summary + ': minutes -1'); |
michael@0 | 58 | |
michael@0 | 59 | expect = 59; |
michael@0 | 60 | actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, -1)).getUTCSeconds()); |
michael@0 | 61 | reportCompare(expect, actual, summary + ': seconds -1'); |
michael@0 | 62 | |
michael@0 | 63 | expect = 999; |
michael@0 | 64 | actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, 0, -1)).getUTCMilliseconds()); |
michael@0 | 65 | reportCompare(expect, actual, summary + ': milliseconds -1'); |
michael@0 | 66 | |
michael@0 | 67 | // |
michael@0 | 68 | |
michael@0 | 69 | expect = true; |
michael@0 | 70 | actual = isNaN(new Date(Date.UTC(2006, 0, undefined)).getUTCDate()); |
michael@0 | 71 | reportCompare(expect, actual, summary + ': date undefined'); |
michael@0 | 72 | |
michael@0 | 73 | expect = true; |
michael@0 | 74 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, undefined)).getUTCHours()); |
michael@0 | 75 | reportCompare(expect, actual, summary + ': hours undefined'); |
michael@0 | 76 | |
michael@0 | 77 | expect = true; |
michael@0 | 78 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, undefined)).getUTCMinutes()); |
michael@0 | 79 | reportCompare(expect, actual, summary + ': minutes undefined'); |
michael@0 | 80 | |
michael@0 | 81 | expect = true; |
michael@0 | 82 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, undefined)).getUTCSeconds()); |
michael@0 | 83 | reportCompare(expect, actual, summary + ': seconds undefined'); |
michael@0 | 84 | |
michael@0 | 85 | expect = true; |
michael@0 | 86 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, undefined)).getUTCMilliseconds()); |
michael@0 | 87 | reportCompare(expect, actual, summary + ': milliseconds undefined'); |
michael@0 | 88 | |
michael@0 | 89 | // |
michael@0 | 90 | |
michael@0 | 91 | expect = true; |
michael@0 | 92 | actual = isNaN(new Date(Date.UTC(2006, 0, {})).getUTCDate()); |
michael@0 | 93 | reportCompare(expect, actual, summary + ': date {}'); |
michael@0 | 94 | |
michael@0 | 95 | expect = true; |
michael@0 | 96 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, {})).getUTCHours()); |
michael@0 | 97 | reportCompare(expect, actual, summary + ': hours {}'); |
michael@0 | 98 | |
michael@0 | 99 | expect = true; |
michael@0 | 100 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, {})).getUTCMinutes()); |
michael@0 | 101 | reportCompare(expect, actual, summary + ': minutes {}'); |
michael@0 | 102 | |
michael@0 | 103 | expect = true; |
michael@0 | 104 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, {})).getUTCSeconds()); |
michael@0 | 105 | reportCompare(expect, actual, summary + ': seconds {}'); |
michael@0 | 106 | |
michael@0 | 107 | expect = true; |
michael@0 | 108 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, {})).getUTCMilliseconds()); |
michael@0 | 109 | reportCompare(expect, actual, summary + ': milliseconds {}'); |
michael@0 | 110 | |
michael@0 | 111 | // |
michael@0 | 112 | |
michael@0 | 113 | expect = 31; |
michael@0 | 114 | actual = (new Date(Date.UTC(2006, 0, null)).getUTCDate()); |
michael@0 | 115 | reportCompare(expect, actual, summary + ': date null'); |
michael@0 | 116 | |
michael@0 | 117 | expect = 0; |
michael@0 | 118 | actual = (new Date(Date.UTC(2006, 0, 0, null)).getUTCHours()); |
michael@0 | 119 | reportCompare(expect, actual, summary + ': hours null'); |
michael@0 | 120 | |
michael@0 | 121 | expect = 0; |
michael@0 | 122 | actual = (new Date(Date.UTC(2006, 0, 0, 0, null)).getUTCMinutes()); |
michael@0 | 123 | reportCompare(expect, actual, summary + ': minutes null'); |
michael@0 | 124 | |
michael@0 | 125 | expect = 0; |
michael@0 | 126 | actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, null)).getUTCSeconds()); |
michael@0 | 127 | reportCompare(expect, actual, summary + ': seconds null'); |
michael@0 | 128 | |
michael@0 | 129 | expect = 0; |
michael@0 | 130 | actual = (new Date(Date.UTC(2006, 0, 0, 0, 0, 0, null)).getUTCMilliseconds()); |
michael@0 | 131 | reportCompare(expect, actual, summary + ': milliseconds null'); |
michael@0 | 132 | |
michael@0 | 133 | // |
michael@0 | 134 | |
michael@0 | 135 | expect = true; |
michael@0 | 136 | actual = isNaN(new Date(Date.UTC(2006, 0, Infinity)).getUTCDate()); |
michael@0 | 137 | reportCompare(expect, actual, summary + ': date Infinity'); |
michael@0 | 138 | |
michael@0 | 139 | expect = true; |
michael@0 | 140 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, Infinity)).getUTCHours()); |
michael@0 | 141 | reportCompare(expect, actual, summary + ': hours Infinity'); |
michael@0 | 142 | |
michael@0 | 143 | expect = true; |
michael@0 | 144 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, Infinity)).getUTCMinutes()); |
michael@0 | 145 | reportCompare(expect, actual, summary + ': minutes Infinity'); |
michael@0 | 146 | |
michael@0 | 147 | expect = true; |
michael@0 | 148 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, Infinity)).getUTCSeconds()); |
michael@0 | 149 | reportCompare(expect, actual, summary + ': seconds Infinity'); |
michael@0 | 150 | |
michael@0 | 151 | expect = true; |
michael@0 | 152 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, Infinity)).getUTCMilliseconds()); |
michael@0 | 153 | reportCompare(expect, actual, summary + ': milliseconds Infinity'); |
michael@0 | 154 | |
michael@0 | 155 | // |
michael@0 | 156 | |
michael@0 | 157 | expect = true; |
michael@0 | 158 | actual = isNaN(new Date(Date.UTC(2006, 0, -Infinity)).getUTCDate()); |
michael@0 | 159 | reportCompare(expect, actual, summary + ': date -Infinity'); |
michael@0 | 160 | |
michael@0 | 161 | expect = true; |
michael@0 | 162 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, -Infinity)).getUTCHours()); |
michael@0 | 163 | reportCompare(expect, actual, summary + ': hours -Infinity'); |
michael@0 | 164 | |
michael@0 | 165 | expect = true; |
michael@0 | 166 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, -Infinity)).getUTCMinutes()); |
michael@0 | 167 | reportCompare(expect, actual, summary + ': minutes -Infinity'); |
michael@0 | 168 | |
michael@0 | 169 | expect = true; |
michael@0 | 170 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, -Infinity)).getUTCSeconds()); |
michael@0 | 171 | reportCompare(expect, actual, summary + ': seconds -Infinity'); |
michael@0 | 172 | |
michael@0 | 173 | expect = true; |
michael@0 | 174 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, -Infinity)).getUTCMilliseconds()); |
michael@0 | 175 | reportCompare(expect, actual, summary + ': milliseconds -Infinity'); |
michael@0 | 176 | |
michael@0 | 177 | // |
michael@0 | 178 | |
michael@0 | 179 | expect = true; |
michael@0 | 180 | actual = isNaN(new Date(Date.UTC(2006, 0, NaN)).getUTCDate()); |
michael@0 | 181 | reportCompare(expect, actual, summary + ': date NaN'); |
michael@0 | 182 | |
michael@0 | 183 | expect = true; |
michael@0 | 184 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, NaN)).getUTCHours()); |
michael@0 | 185 | reportCompare(expect, actual, summary + ': hours NaN'); |
michael@0 | 186 | |
michael@0 | 187 | expect = true; |
michael@0 | 188 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, NaN)).getUTCMinutes()); |
michael@0 | 189 | reportCompare(expect, actual, summary + ': minutes NaN'); |
michael@0 | 190 | |
michael@0 | 191 | expect = true; |
michael@0 | 192 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, NaN)).getUTCSeconds()); |
michael@0 | 193 | reportCompare(expect, actual, summary + ': seconds NaN'); |
michael@0 | 194 | |
michael@0 | 195 | expect = true; |
michael@0 | 196 | actual = isNaN(new Date(Date.UTC(2006, 0, 0, 0, 0, 0, NaN)).getUTCMilliseconds()); |
michael@0 | 197 | reportCompare(expect, actual, summary + ': milliseconds NaN'); |
michael@0 | 198 | |
michael@0 | 199 | exitFunc ('test'); |
michael@0 | 200 | } |