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 = 301738; |
michael@0 | 8 | var summary = 'Date parse compatibilty with MSIE'; |
michael@0 | 9 | var actual = ''; |
michael@0 | 10 | var expect = ''; |
michael@0 | 11 | |
michael@0 | 12 | printBugNumber(BUGNUMBER); |
michael@0 | 13 | printStatus (summary); |
michael@0 | 14 | |
michael@0 | 15 | /* |
michael@0 | 16 | Case 1. The input string contains an English month name. |
michael@0 | 17 | The form of the string can be month f l, or f month l, or |
michael@0 | 18 | f l month which each evaluate to the same date. |
michael@0 | 19 | If f and l are both greater than or equal to 70, or |
michael@0 | 20 | both less than 70, the date is invalid. |
michael@0 | 21 | The year is taken to be the greater of the values f, l. |
michael@0 | 22 | If the year is greater than or equal to 70 and less than 100, |
michael@0 | 23 | it is considered to be the number of years after 1900. |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | var month = 'January'; |
michael@0 | 27 | var f; |
michael@0 | 28 | var l; |
michael@0 | 29 | |
michael@0 | 30 | f = l = 0; |
michael@0 | 31 | expect = true; |
michael@0 | 32 | |
michael@0 | 33 | actual = isNaN(new Date(month + ' ' + f + ' ' + l)); |
michael@0 | 34 | reportCompare(expect, actual, 'January 0 0 is invalid'); |
michael@0 | 35 | |
michael@0 | 36 | actual = isNaN(new Date(f + ' ' + l + ' ' + month)); |
michael@0 | 37 | reportCompare(expect, actual, '0 0 January is invalid'); |
michael@0 | 38 | |
michael@0 | 39 | actual = isNaN(new Date(f + ' ' + month + ' ' + l)); |
michael@0 | 40 | reportCompare(expect, actual, '0 January 0 is invalid'); |
michael@0 | 41 | |
michael@0 | 42 | f = l = 70; |
michael@0 | 43 | |
michael@0 | 44 | actual = isNaN(new Date(month + ' ' + f + ' ' + l)); |
michael@0 | 45 | reportCompare(expect, actual, 'January 70 70 is invalid'); |
michael@0 | 46 | |
michael@0 | 47 | actual = isNaN(new Date(f + ' ' + l + ' ' + month)); |
michael@0 | 48 | reportCompare(expect, actual, '70 70 January is invalid'); |
michael@0 | 49 | |
michael@0 | 50 | actual = isNaN(new Date(f + ' ' + month + ' ' + l)); |
michael@0 | 51 | reportCompare(expect, actual, '70 January 70 is invalid'); |
michael@0 | 52 | |
michael@0 | 53 | f = 100; |
michael@0 | 54 | l = 15; |
michael@0 | 55 | |
michael@0 | 56 | // year, month, day |
michael@0 | 57 | expect = new Date(f, 0, l).toString(); |
michael@0 | 58 | |
michael@0 | 59 | actual = new Date(month + ' ' + f + ' ' + l).toString(); |
michael@0 | 60 | reportCompare(expect, actual, 'month f l'); |
michael@0 | 61 | |
michael@0 | 62 | actual = new Date(f + ' ' + l + ' ' + month).toString(); |
michael@0 | 63 | reportCompare(expect, actual, 'f l month'); |
michael@0 | 64 | |
michael@0 | 65 | actual = new Date(f + ' ' + month + ' ' + l).toString(); |
michael@0 | 66 | reportCompare(expect, actual, 'f month l'); |
michael@0 | 67 | |
michael@0 | 68 | f = 80; |
michael@0 | 69 | l = 15; |
michael@0 | 70 | |
michael@0 | 71 | // year, month, day |
michael@0 | 72 | expect = (new Date(f, 0, l)).toString(); |
michael@0 | 73 | |
michael@0 | 74 | actual = (new Date(month + ' ' + f + ' ' + l)).toString(); |
michael@0 | 75 | reportCompare(expect, actual, 'month f l'); |
michael@0 | 76 | |
michael@0 | 77 | actual = (new Date(f + ' ' + l + ' ' + month)).toString(); |
michael@0 | 78 | reportCompare(expect, actual, 'f l month'); |
michael@0 | 79 | |
michael@0 | 80 | actual = (new Date(f + ' ' + month + ' ' + l)).toString(); |
michael@0 | 81 | reportCompare(expect, actual, 'f month l'); |
michael@0 | 82 | |
michael@0 | 83 | f = 2040; |
michael@0 | 84 | l = 15; |
michael@0 | 85 | |
michael@0 | 86 | // year, month, day |
michael@0 | 87 | expect = (new Date(f, 0, l)).toString(); |
michael@0 | 88 | |
michael@0 | 89 | actual = (new Date(month + ' ' + f + ' ' + l)).toString(); |
michael@0 | 90 | reportCompare(expect, actual, 'month f l'); |
michael@0 | 91 | |
michael@0 | 92 | actual = (new Date(f + ' ' + l + ' ' + month)).toString(); |
michael@0 | 93 | reportCompare(expect, actual, 'f l month'); |
michael@0 | 94 | |
michael@0 | 95 | actual = (new Date(f + ' ' + month + ' ' + l)).toString(); |
michael@0 | 96 | reportCompare(expect, actual, 'f month l'); |
michael@0 | 97 |