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 | // 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 language tags with "_" are not accepted. |
michael@0 | 6 | * @author Norbert Lindenberg |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | $INCLUDE("testIntl.js"); |
michael@0 | 10 | |
michael@0 | 11 | var invalidLanguageTags = [ |
michael@0 | 12 | "de_DE", |
michael@0 | 13 | "DE_de", |
michael@0 | 14 | "cmn_Hans", |
michael@0 | 15 | "cmn-hans_cn", |
michael@0 | 16 | "es_419", |
michael@0 | 17 | "es-419-u-nu-latn-cu_bob", |
michael@0 | 18 | "i_klingon", |
michael@0 | 19 | "cmn-hans-cn-t-ca-u-ca-x_t-u", |
michael@0 | 20 | "enochian_enochian", |
michael@0 | 21 | "de-gregory_u-ca-gregory" |
michael@0 | 22 | ]; |
michael@0 | 23 | |
michael@0 | 24 | testWithIntlConstructors(function (Constructor) { |
michael@0 | 25 | invalidLanguageTags.forEach(function (tag) { |
michael@0 | 26 | var error; |
michael@0 | 27 | try { |
michael@0 | 28 | // this must throw an exception for an invalid language tag |
michael@0 | 29 | var obj = new Constructor([tag]); |
michael@0 | 30 | } catch (e) { |
michael@0 | 31 | error = e; |
michael@0 | 32 | } |
michael@0 | 33 | if (error === undefined) { |
michael@0 | 34 | $ERROR("Invalid language tag " + tag + " was not rejected."); |
michael@0 | 35 | } else if (error.name !== "RangeError") { |
michael@0 | 36 | $ERROR("Invalid language tag " + tag + " was rejected with wrong error " + error.name + "."); |
michael@0 | 37 | } |
michael@0 | 38 | }); |
michael@0 | 39 | return true; |
michael@0 | 40 | }); |
michael@0 | 41 |