| 1 |
// Copyright 2012 Mozilla Corporation. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
es5id: 6.4_c |
| 6 |
description: > |
| 7 |
Tests that additional time zone names, if accepted, are handled |
| 8 |
correctly. |
| 9 |
author: Norbert Lindenberg |
| 10 |
---*/ |
| 11 |
|
| 12 |
// canonicalization specified in conformance clause |
| 13 |
var additionalTimeZoneNames = { |
| 14 |
"Etc/GMT": "UTC", |
| 15 |
"Greenwich": "UTC", |
| 16 |
"PRC": "Asia/Shanghai", |
| 17 |
"AmErIcA/LoS_aNgElEs": "America/Los_Angeles", |
| 18 |
"etc/gmt+7": "Etc/GMT+7" |
| 19 |
}; |
| 20 |
|
| 21 |
Object.getOwnPropertyNames(additionalTimeZoneNames).forEach(function (name) { |
| 22 |
var format, error; |
| 23 |
try { |
| 24 |
format = new Intl.DateTimeFormat([], {timeZone: name}); |
| 25 |
} catch (e) { |
| 26 |
error = e; |
| 27 |
} |
| 28 |
if (error === undefined) { |
| 29 |
var actual = format.resolvedOptions().timeZone; |
| 30 |
var expected = additionalTimeZoneNames[name]; |
| 31 |
assert.sameValue(actual, expected, "Time zone name " + name + " was accepted, but incorrectly canonicalized."); |
| 32 |
} else { |
| 33 |
assert(error instanceof RangeError, "Time zone name " + name + " was rejected with wrong error " + error.name + "."); |
| 34 |
} |
| 35 |
}); |