1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.intl;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.htmlunit.junit.annotation.HtmlUnitNYI;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23
24
25
26
27
28
29 @RunWith(BrowserRunner.class)
30 public class NumberFormatTest extends WebDriverTestCase {
31
32
33
34
35 @Test
36 @Alerts({"zh-CN", "latn", "standard", "auto", "decimal", "1", "0", "3", "auto"})
37 @HtmlUnitNYI(CHROME = {"undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined",
38 "undefined", "undefined"},
39 EDGE = {"undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined",
40 "undefined", "undefined"},
41 FF = {"undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined",
42 "undefined", "undefined"},
43 FF_ESR = {"undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined",
44 "undefined", "undefined"})
45 public void resolvedOptionsValues() throws Exception {
46 final String html = DOCTYPE_HTML
47 + "<html><head>\n"
48 + "<script>\n"
49 + LOG_TITLE_FUNCTION
50 + " function test() {\n"
51 + " var region1 = new Intl.NumberFormat('zh-CN');\n"
52 + " var options = region1.resolvedOptions();\n"
53 + " log(options.locale);\n"
54 + " log(options.numberingSystem);\n"
55 + " log(options.notation);\n"
56 + " log(options.signDisplay);\n"
57 + " log(options.style);\n"
58 + " log(options.minimumIntegerDigits);\n"
59 + " log(options.minimumFractionDigits);\n"
60 + " log(options.maximumFractionDigits);\n"
61 + " log(options.useGrouping);\n"
62 + " }\n"
63 + "</script>\n"
64 + "</head>\n"
65 + "<body onload='test()'>\n"
66 + "</body></html>";
67
68 loadPageVerifyTitle2(html);
69 }
70
71
72
73
74 @Test
75 @Alerts("[object Object]")
76 public void resolvedOptions() throws Exception {
77 final String html = DOCTYPE_HTML
78 + "<html><head>\n"
79 + "<script>\n"
80 + LOG_TITLE_FUNCTION
81 + " function test() {\n"
82 + " var region1 = new Intl.NumberFormat('zh-CN');\n"
83 + " var options = region1.resolvedOptions();\n"
84 + " log(options);\n"
85 + " }\n"
86 + "</script>\n"
87 + "</head>\n"
88 + "<body onload='test()'>\n"
89 + "</body></html>";
90
91 loadPageVerifyTitle2(html);
92 }
93
94
95
96
97 @Test
98 @Alerts({"true", "42.247"})
99 public void numberFormat() throws Exception {
100 final String html = DOCTYPE_HTML
101 + "<html><head>\n"
102 + "<script>\n"
103 + LOG_TITLE_FUNCTION
104 + " function test() {\n"
105 + " var numberFormat = Intl.NumberFormat('en');\n"
106 + " log(numberFormat instanceof Intl.NumberFormat);\n"
107
108 + " log(numberFormat.format(42.2468));\n"
109 + " }\n"
110 + "</script>\n"
111 + "</head>\n"
112 + "<body onload='test()'>\n"
113 + "</body></html>";
114
115 loadPageVerifyTitle2(html);
116 }
117 }