blob: 8fcd8d895ed0635c372f680646e1b58fc8c9a667 [file] [log] [blame]
commit-queue@webkit.org0c12ae72018-07-26 16:01:04 +00001<!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.orgb6113b42018-08-01 21:13:10 +00009description("This test checks the default locale behavior of Intl constructors.");
10
11// Actual default should always be a string
12shouldBe("typeof new Intl.DateTimeFormat().resolvedOptions().locale", "'string'");
13shouldBe("typeof new Intl.NumberFormat().resolvedOptions().locale", "'string'");
14shouldBe("typeof new Intl.Collator().resolvedOptions().locale", "'string'");
15
16// Actual default should always be canonicalized
17shouldBe("Intl.getCanonicalLocales(new Intl.DateTimeFormat().resolvedOptions().locale)[0]", "new Intl.DateTimeFormat().resolvedOptions().locale");
18shouldBe("Intl.getCanonicalLocales(new Intl.NumberFormat().resolvedOptions().locale)[0]", "new Intl.NumberFormat().resolvedOptions().locale");
19shouldBe("Intl.getCanonicalLocales(new Intl.Collator().resolvedOptions().locale)[0]", "new Intl.NumberFormat().resolvedOptions().locale");
20
commit-queue@webkit.org0c12ae72018-07-26 16:01:04 +000021if (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.orgb6113b42018-08-01 21:13:10 +000026 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.org0c12ae72018-07-26 16:01:04 +000029}
commit-queue@webkit.org0c12ae72018-07-26 16:01:04 +000030</script>
31<script src="../resources/js-test-post.js"></script>
32</body>
33</html>