Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | // Copyright 2012 Mozilla Corporation. All rights reserved. |
michael@0 | 2 | // This code is governed by the BSD license found in the LICENSE file. |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * @description Tests that invalid time zone names are not accepted. |
michael@0 | 6 | * @author Norbert Lindenberg |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | var invalidTimeZoneNames = [ |
michael@0 | 10 | "", |
michael@0 | 11 | "MEZ", // localized abbreviation |
michael@0 | 12 | "Pacific Time", // localized long form |
michael@0 | 13 | "cnsha", // BCP 47 time zone code |
michael@0 | 14 | "invalid", // as the name says |
michael@0 | 15 | "Europe/İstanbul", // non-ASCII letter |
michael@0 | 16 | "asıa/baku", // non-ASCII letter |
michael@0 | 17 | "europe/brußels" // non-ASCII letter |
michael@0 | 18 | ]; |
michael@0 | 19 | |
michael@0 | 20 | invalidTimeZoneNames.forEach(function (name) { |
michael@0 | 21 | var error; |
michael@0 | 22 | try { |
michael@0 | 23 | // this must throw an exception for an invalid time zone name |
michael@0 | 24 | var format = new Intl.DateTimeFormat(["de-de"], {timeZone: name}); |
michael@0 | 25 | } catch (e) { |
michael@0 | 26 | error = e; |
michael@0 | 27 | } |
michael@0 | 28 | if (error === undefined) { |
michael@0 | 29 | $ERROR("Invalid time zone name " + name + " was not rejected."); |
michael@0 | 30 | } else if (error.name !== "RangeError") { |
michael@0 | 31 | $ERROR("Invalid time zone name " + name + " was rejected with wrong error " + error.name + "."); |
michael@0 | 32 | } |
michael@0 | 33 | }); |
michael@0 | 34 |