|
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 * @description Tests that LookupSupportedLocales includes the default locale |
|
6 * and doesn't include the "no linguistic content" locale. |
|
7 * @author Norbert Lindenberg |
|
8 */ |
|
9 |
|
10 $INCLUDE("testIntl.js"); |
|
11 |
|
12 testWithIntlConstructors(function (Constructor) { |
|
13 // this test should work equally for both matching algorithms |
|
14 ["lookup", "best fit"].forEach(function (matcher) { |
|
15 var defaultLocale = new Constructor().resolvedOptions().locale; |
|
16 var noLinguisticContent = "zxx"; |
|
17 var supported = Constructor.supportedLocalesOf([defaultLocale, noLinguisticContent], |
|
18 {localeMatcher: matcher}); |
|
19 if (supported.indexOf(defaultLocale) === -1) { |
|
20 $ERROR("SupportedLocales didn't return default locale with matcher " + matcher + "."); |
|
21 } |
|
22 if (supported.indexOf(noLinguisticContent) !== -1) { |
|
23 $ERROR("SupportedLocales returned the \"no linguistic content\" locale with matcher " + matcher + "."); |
|
24 } |
|
25 if (supported.length > 1) { |
|
26 $ERROR("SupportedLocales returned stray locales: " + supported.join(", ") + " with matcher " + matcher + "."); |
|
27 } |
|
28 }); |
|
29 |
|
30 return true; |
|
31 }); |
|
32 |