commit-queue@webkit.org | 0c12ae7 | 2018-07-26 16:01:04 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <script src="../resources/js-test-pre.js"></script> |
| 6 | </head> |
| 7 | <body> |
| 8 | <script> |
commit-queue@webkit.org | b6113b4 | 2018-08-01 21:13:10 +0000 | [diff] [blame] | 9 | description("This test checks the default locale behavior of Intl constructors."); |
| 10 | |
| 11 | // Actual default should always be a string |
| 12 | shouldBe("typeof new Intl.DateTimeFormat().resolvedOptions().locale", "'string'"); |
| 13 | shouldBe("typeof new Intl.NumberFormat().resolvedOptions().locale", "'string'"); |
| 14 | shouldBe("typeof new Intl.Collator().resolvedOptions().locale", "'string'"); |
| 15 | |
| 16 | // Actual default should always be canonicalized |
| 17 | shouldBe("Intl.getCanonicalLocales(new Intl.DateTimeFormat().resolvedOptions().locale)[0]", "new Intl.DateTimeFormat().resolvedOptions().locale"); |
| 18 | shouldBe("Intl.getCanonicalLocales(new Intl.NumberFormat().resolvedOptions().locale)[0]", "new Intl.NumberFormat().resolvedOptions().locale"); |
| 19 | shouldBe("Intl.getCanonicalLocales(new Intl.Collator().resolvedOptions().locale)[0]", "new Intl.NumberFormat().resolvedOptions().locale"); |
| 20 | |
commit-queue@webkit.org | 0c12ae7 | 2018-07-26 16:01:04 +0000 | [diff] [blame] | 21 | if (window.internals) { |
| 22 | // Any language name with less than two characters is considered invalid, so we use "a" here. |
| 23 | // "i-klingon" is grandfathered, and is canonicalized "tlh". |
| 24 | // It should not be part of any available locale sets, so we know it came from here. |
| 25 | window.internals.setUserPreferredLanguages([ "a", "*", "en_US.utf8", "i-klingon", "en-US" ]); |
commit-queue@webkit.org | b6113b4 | 2018-08-01 21:13:10 +0000 | [diff] [blame] | 26 | shouldBe("new Intl.DateTimeFormat().resolvedOptions().locale", "'tlh'"); |
| 27 | shouldBe("new Intl.NumberFormat().resolvedOptions().locale", "'tlh'"); |
| 28 | shouldBe("new Intl.Collator().resolvedOptions().locale", "'tlh'"); |
commit-queue@webkit.org | 0c12ae7 | 2018-07-26 16:01:04 +0000 | [diff] [blame] | 29 | } |
commit-queue@webkit.org | 0c12ae7 | 2018-07-26 16:01:04 +0000 | [diff] [blame] | 30 | </script> |
| 31 | <script src="../resources/js-test-post.js"></script> |
| 32 | </body> |
| 33 | </html> |