Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / script-tests / i18n-bindings-locale.js
blobf453d72030cc5cf415274432d3528561e80615b9
1 description(
3 "This test checks properties and methods of Locale object."
5 );
7 function reportResult(_actual, _expected) {
8 if (isResultCorrect(_actual, _expected))
9 testPassed(_actual + ' is ' + _expected);
10 else
11 testFailed(_actual + ' should be ' + _expected);
14 localeTests = function() {
15 this.defaultLocale = function() {
16 var locale = new v8Locale();
17 reportResult(locale.locale, 'en-US');
18 reportResult(locale.language, 'en');
19 reportResult(locale.script, undefined);
20 reportResult(locale.region, 'US');
23 this.baseLocale = function() {
24 var locale = new v8Locale('sr');
25 reportResult(locale.locale, 'sr');
26 reportResult(locale.language, 'sr');
27 reportResult(locale.script, undefined);
28 reportResult(locale.region, undefined);
31 this.languageScriptLocale = function() {
32 var locale = new v8Locale('zh-Hans');
33 reportResult(locale.locale, 'zh-Hans');
34 reportResult(locale.language, 'zh');
35 reportResult(locale.script, 'Hans');
36 reportResult(locale.region, undefined);
39 this.languageScriptRegionLocale = function() {
40 var locale = new v8Locale('zh-Hans-CN');
41 reportResult(locale.locale, 'zh-Hans-CN');
42 reportResult(locale.language, 'zh');
43 reportResult(locale.script, 'Hans');
44 reportResult(locale.region, 'CN');
47 this.languageScriptRegionExtensionLocale = function() {
48 var locale = new v8Locale('de-DE@collation=phone');
49 reportResult(locale.locale, 'de-DE@collation=phone');
50 reportResult(locale.language, 'de');
51 reportResult(locale.script, undefined);
52 reportResult(locale.region, 'DE');
55 this.languageScriptRegionDashUExtensionLocale = function() {
56 var locale = new v8Locale('de-DE-u-co-phonebook');
57 reportResult(locale.locale, 'de-DE-u-co-phonebook');
58 reportResult(locale.language, 'de');
59 reportResult(locale.script, undefined);
60 reportResult(locale.region, 'DE');
63 this.availableLocales = function() {
64 var locales = v8Locale.availableLocales();
65 reportResult(locales.length > 100, true);
66 reportResult(locales.join().indexOf('sr') >= 0, true);
69 this.maximizedLocale = function() {
70 var locale = new v8Locale('sr').maximizedLocale();
71 reportResult(locale.locale, 'sr-Cyrl-RS');
72 reportResult(locale.language, 'sr');
73 reportResult(locale.script, 'Cyrl');
74 reportResult(locale.region, 'RS');
77 this.maximizedLocaleWithExtension = function() {
78 var locale = new v8Locale('de@collation=phone').maximizedLocale();
79 reportResult(locale.locale, 'de-Latn-DE@collation=phone');
80 reportResult(locale.language, 'de');
81 reportResult(locale.script, 'Latn');
82 reportResult(locale.region, 'DE');
85 this.minimizedLocale = function() {
86 var locale = new v8Locale('sr-Cyrl-RS').minimizedLocale();
87 reportResult(locale.locale, 'sr');
88 reportResult(locale.language, 'sr');
89 reportResult(locale.script, undefined);
90 reportResult(locale.region, undefined);
93 this.minimizedLocaleWithExtension = function() {
94 var locale = new v8Locale('de-Latn-DE@collation=phone').minimizedLocale();
95 // FIXME: Fix ICU to return de@collation=phone.
96 reportResult(locale.locale, 'de-@collation=phone');
97 reportResult(locale.language, 'de');
98 reportResult(locale.script, undefined);
99 reportResult(locale.region, undefined);
102 this.displayForBaseLocale = function() {
103 var locale = new v8Locale('en');
104 reportResult(locale.displayLanguage(), 'English');
105 reportResult(locale.displayScript(), undefined);
106 reportResult(locale.displayRegion(), undefined);
107 reportResult(locale.displayName(), 'English');
110 this.displayInSameLocale = function() {
111 var locale = new v8Locale('en').maximizedLocale();
112 reportResult(locale.displayLanguage(), 'English');
113 reportResult(locale.displayScript(), 'Latin');
114 reportResult(locale.displayRegion(), 'United States');
115 reportResult(locale.displayName(), 'English (Latin, United States)');
118 this.displayInDifferentLocale = function() {
119 var locale = new v8Locale('sr').maximizedLocale();
120 var displayLocale = new v8Locale('en');
121 reportResult(locale.displayLanguage(displayLocale), 'Serbian');
122 reportResult(locale.displayScript(displayLocale), 'Cyrillic');
123 reportResult(locale.displayRegion(displayLocale), 'Serbia');
124 reportResult(locale.displayName(displayLocale), 'Serbian (Cyrillic, Serbia)');
127 this.displayInCyrillicScript = function() {
128 var locale = new v8Locale('sr').maximizedLocale();
129 reportResult(locale.displayLanguage(), 'Српски');
130 reportResult(locale.displayScript(), 'Ћирилица');
131 reportResult(locale.displayRegion(), 'Србија');
132 reportResult(locale.displayName(), 'Српски (Ћирилица, Србија)');
135 this.displayInHebrewScript = function() {
136 var locale = new v8Locale('he').maximizedLocale();
137 reportResult(locale.displayLanguage(), 'עברית');
138 reportResult(locale.displayScript(), 'עברי');
139 reportResult(locale.displayRegion(), 'ישראל');
140 reportResult(locale.displayName(), 'עברית (עברי, ישראל)');
144 (function() {
145 var allTests = new localeTests();
146 for (var test in allTests) {
147 allTests[test]();
149 })();