| 1 |
// |reftest| skip-if(!this.hasOwnProperty("Intl")) |
| 2 |
|
| 3 |
// Language tags are processed case-insensitive, but unconditionally calling |
| 4 |
// the built-in String.prototype.toLowerCase() or toUpperCase() function |
| 5 |
// before parsing a language tag can map non-ASCII characters into the ASCII |
| 6 |
// range. |
| 7 |
// |
| 8 |
// Validate the Unicode BCP 47 locale identifier parser handles this case |
| 9 |
// (pun intended) correctly by passing language tags which contain |
| 10 |
// U+212A (KELVIN SIGN) and U+0131 (LATIN SMALL LETTER DOTLESS I) to |
| 11 |
// Intl.getCanonicalLocales(). |
| 12 |
|
| 13 |
// The lower-case form of "i-ha\u212A" is "i-hak". |
| 14 |
assertEq("i-hak", "i-ha\u212A".toLowerCase()); |
| 15 |
|
| 16 |
// The upper-case form of "\u0131-hak" is "I-HAK". |
| 17 |
assertEq("I-HAK", "\u0131-hak".toUpperCase()); |
| 18 |
|
| 19 |
// "i-hak" is not a valid Unicode BCP 47 locale identifier. |
| 20 |
assertThrowsInstanceOf(() => Intl.getCanonicalLocales("i-hak"), RangeError); |
| 21 |
|
| 22 |
// And neither is "i-ha\u212A". |
| 23 |
assertThrowsInstanceOf(() => Intl.getCanonicalLocales("i-ha\u212A"), RangeError); |
| 24 |
|
| 25 |
// And also "\u0131-hak" isn't valid. |
| 26 |
assertThrowsInstanceOf(() => Intl.getCanonicalLocales("\u0131-hak"), RangeError); |
| 27 |
|
| 28 |
// The lower-case form of "zh-ha\u212A\u212Aa" is "zh-hakka". |
| 29 |
assertEq("zh-hakka", "zh-ha\u212A\u212Aa".toLowerCase()); |
| 30 |
|
| 31 |
// "zh-hakka" is a valid Unicode BCP 47 locale identifier. |
| 32 |
assertEqArray(Intl.getCanonicalLocales("zh-hakka"), ["hak"]); |
| 33 |
|
| 34 |
// But "zh-ha\u212A\u212Aa" is not a valid locale identifier. |
| 35 |
assertThrowsInstanceOf(() => Intl.getCanonicalLocales("zh-ha\u212A\u212Aa"), RangeError); |
| 36 |
|
| 37 |
// The lower-case form of "zh-x\u0131ang" is "ZH-XIANG". |
| 38 |
assertEq("ZH-XIANG", "zh-x\u0131ang".toUpperCase()); |
| 39 |
|
| 40 |
// "zh-xiang" is a valid Unicode BCP 47 locale identifier. |
| 41 |
assertEqArray(Intl.getCanonicalLocales("zh-xiang"), ["hsn"]); |
| 42 |
|
| 43 |
// But "zh-x\u0131ang" is not a valid locale identifier. |
| 44 |
assertThrowsInstanceOf(() => Intl.getCanonicalLocales("zh-x\u0131ang"), RangeError); |
| 45 |
|
| 46 |
if (typeof reportCompare === 'function') |
| 47 |
reportCompare(0, 0); |