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