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 structurally valid language tags are 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 validLanguageTags = [ |
michael@0 | 12 | "de", // ISO 639 language code |
michael@0 | 13 | "de-DE", // + ISO 3166-1 country code |
michael@0 | 14 | "DE-de", // tags are case-insensitive |
michael@0 | 15 | "cmn", // ISO 639 language code |
michael@0 | 16 | "cmn-Hans", // + script code |
michael@0 | 17 | "CMN-hANS", // tags are case-insensitive |
michael@0 | 18 | "cmn-hans-cn", // + ISO 3166-1 country code |
michael@0 | 19 | "es-419", // + UN M.49 region code |
michael@0 | 20 | "es-419-u-nu-latn-cu-bob", // + Unicode locale extension sequence |
michael@0 | 21 | "i-klingon", // grandfathered tag |
michael@0 | 22 | "cmn-hans-cn-t-ca-u-ca-x-t-u", // singleton subtags can also be used as private use subtags |
michael@0 | 23 | "enochian-enochian", // language and variant subtags may be the same |
michael@0 | 24 | "de-gregory-u-ca-gregory", // variant and extension subtags may be the same |
michael@0 | 25 | "aa-a-foo-x-a-foo-bar", // variant subtags can also be used as private use subtags |
michael@0 | 26 | "x-en-US-12345", // anything goes in private use tags |
michael@0 | 27 | "x-12345-12345-en-US", |
michael@0 | 28 | "x-en-US-12345-12345", |
michael@0 | 29 | "x-en-u-foo", |
michael@0 | 30 | "x-en-u-foo-u-bar" |
michael@0 | 31 | ]; |
michael@0 | 32 | |
michael@0 | 33 | testWithIntlConstructors(function (Constructor) { |
michael@0 | 34 | validLanguageTags.forEach(function (tag) { |
michael@0 | 35 | // this must not throw an exception for a valid language tag |
michael@0 | 36 | var obj = new Constructor([tag]); |
michael@0 | 37 | }); |
michael@0 | 38 | return true; |
michael@0 | 39 | }); |
michael@0 | 40 |