2150 |
mathias |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
|
2 |
"http://www.w3.org/TR/html4/strict.dtd">
|
|
|
3 |
<html>
|
|
|
4 |
<head>
|
|
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
6 |
<title>Test CurrencyTextBox</title>
|
|
|
7 |
|
|
|
8 |
<script type="text/javascript" src="../../../dojo/dojo.js"
|
|
|
9 |
djConfig="isDebug: true, extraLocale: ['zh-cn','fr-fr','ja-jp','ar-eg']"></script>
|
|
|
10 |
<script type="text/javascript" src="../../../dojo/currency.js"></script>
|
|
|
11 |
<script type="text/javascript" src="../../../dojo/number.js"></script>
|
|
|
12 |
<script type="text/javascript">
|
|
|
13 |
dojo.require("dijit.form.NumberTextBox");
|
|
|
14 |
dojo.require("dijit.form.CurrencyTextBox");
|
|
|
15 |
dojo.require("dijit.form.DateTextBox");
|
|
|
16 |
dojo.require("dijit.form.ValidationTextBox");
|
|
|
17 |
dojo.require("dojo.date.locale");
|
|
|
18 |
dojo.require("dojo.date.stamp");
|
|
|
19 |
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
|
|
|
20 |
dojo.require("doh.runner");
|
|
|
21 |
</script>
|
|
|
22 |
<script src="test_i18n.js"></script>
|
|
|
23 |
<script type="text/javascript">
|
|
|
24 |
dojo.addOnLoad(function(){
|
|
|
25 |
doh.register("t", getAllTestCases());
|
|
|
26 |
doh.run();
|
|
|
27 |
});
|
|
|
28 |
</script>
|
|
|
29 |
|
|
|
30 |
<style type="text/css">
|
|
|
31 |
@import "../../../dojo/resources/dojo.css";
|
|
|
32 |
@import "../../themes/tundra/tundra.css";
|
|
|
33 |
@import "../css/dijitTests.css";
|
|
|
34 |
|
|
|
35 |
.title {
|
|
|
36 |
background-color:#ddd;
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
.hint {
|
|
|
40 |
background-color:#eee;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
.testExample {
|
|
|
44 |
background-color:#fbfbfb;
|
|
|
45 |
padding:1em;
|
|
|
46 |
margin-bottom:1em;
|
|
|
47 |
border:1px solid #bfbfbf;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
.dojoTitlePaneLabel label {
|
|
|
51 |
font-weight:bold;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
td {white-space:nowrap}
|
|
|
55 |
</style>
|
|
|
56 |
</head>
|
|
|
57 |
|
|
|
58 |
<body class="tundra">
|
|
|
59 |
<h1 class="testTitle">Dijit TextBox Globalization Test for Currency</h1>
|
|
|
60 |
|
|
|
61 |
<!-- <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2>
|
|
|
62 |
<button id="startButton" onclick="startTest()">Start Test</button> -->
|
|
|
63 |
<p>
|
|
|
64 |
Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", "ja-jp" and "ar-eg"
|
|
|
65 |
and currencies CNY, EGP, EUR, JPY. If not, convert these CLDR data and put them there.
|
|
|
66 |
</p>
|
|
|
67 |
|
|
|
68 |
<script>
|
|
|
69 |
(function() {
|
|
|
70 |
genFormatTestCases("Currency Format", "dijit.form.CurrencyTextBox", [
|
|
|
71 |
|
|
|
72 |
{ attrs: {Currency: "CNY", lang: "zh-cn"},
|
|
|
73 |
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
|
|
|
74 |
value: "123456789.46",
|
|
|
75 |
expValue: "¥123,456,789.46",
|
|
|
76 |
comment: ""
|
|
|
77 |
},
|
|
|
78 |
{ attrs: {Currency: "CNY", lang: "zh-cn"},
|
|
|
79 |
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
|
|
|
80 |
value: "-123456789.46",
|
|
|
81 |
expValue: "-¥123,456,789.46",
|
|
|
82 |
comment: ""
|
|
|
83 |
},
|
|
|
84 |
|
|
|
85 |
{ attrs: {Currency: "EUR", lang: "fr-fr"},
|
|
|
86 |
desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>",
|
|
|
87 |
value: "123456789.46",
|
|
|
88 |
expValue: "123 456 789,46 €",
|
|
|
89 |
comment: "Failed in IE: the currency textbox should not reject the value generated by itself. <a href='#cmt_1'>See #1.</a>"
|
|
|
90 |
},
|
|
|
91 |
{ attrs: {Currency: "EUR", lang: "fr-fr"},
|
|
|
92 |
desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>",
|
|
|
93 |
value: "-123456789.46",
|
|
|
94 |
expValue: "-123 456 789,46 €",
|
|
|
95 |
comment: "Failed in IE: the currency textbox should not reject the value generated by itself. <a href='#cmt_1'>See #1.</a>"
|
|
|
96 |
},
|
|
|
97 |
|
|
|
98 |
{ attrs: {Currency: "JPY", lang: "ja-jp"},
|
|
|
99 |
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
|
|
|
100 |
value: "123456789.46",
|
|
|
101 |
expValue: "¥123,456,789",
|
|
|
102 |
comment: ""
|
|
|
103 |
},
|
|
|
104 |
{ attrs: {Currency: "JPY", lang: "ja-jp"},
|
|
|
105 |
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
|
|
|
106 |
value: "-123456789.46",
|
|
|
107 |
expValue: "-¥123,456,789",
|
|
|
108 |
comment: ""
|
|
|
109 |
},
|
|
|
110 |
|
|
|
111 |
{ attrs: {Currency: "EGP", lang: "ar-eg"},
|
|
|
112 |
desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>",
|
|
|
113 |
value: "123456789.46",
|
|
|
114 |
expValue: "ج.م.\u200F 123٬456٬789٫46",
|
|
|
115 |
comment: "Failed in Firefox. <a href='#cmt_2'>See #2.</a>"
|
|
|
116 |
},
|
|
|
117 |
{ attrs: {Currency: "EGP", lang: "ar-eg"},
|
|
|
118 |
desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>",
|
|
|
119 |
value: "-123456789.46",
|
|
|
120 |
expValue: "ج.م.\u200F 123٬456٬789٫46-",
|
|
|
121 |
comment: "Failed in Firefox. <a href='#cmt_2'>See #2.</a>"
|
|
|
122 |
},
|
|
|
123 |
|
|
|
124 |
{ attrs: {Currency: "EGP", lang: "ar-eg", constraints: "{localeDigit: true}"},
|
|
|
125 |
desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>",
|
|
|
126 |
value: "123456789.46",
|
|
|
127 |
expValue: "ج.م.\u200F ١٢٣\u066C٤٥٦\u066C٧٨٩\u066B٤٦",
|
|
|
128 |
comment: "<a href='#cmt_3'>See #3.</a> Failed in Firefox. <a href='#cmt_2'>See #2.</a>"
|
|
|
129 |
},
|
|
|
130 |
{ attrs: {Currency: "EGP", lang: "ar-eg", constraints: "{localeDigit: true}"},
|
|
|
131 |
desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>",
|
|
|
132 |
value: "-123456789.46",
|
|
|
133 |
expValue: "ج.م.\u200F ١٢٣\u066C٤٥٦\u066C٧٨٩\u066B٤٦-",
|
|
|
134 |
comment: "<a href='#cmt_3'>See #3.</a> Failed in Firefox. <a href='#cmt_2'>See #2.</a>"
|
|
|
135 |
}
|
|
|
136 |
]);
|
|
|
137 |
|
|
|
138 |
genValidateTestCases("Currency Validate", "dijit.form.CurrencyTextBox", [
|
|
|
139 |
|
|
|
140 |
{ attrs: {Currency: "CNY", lang: "zh-cn"},
|
|
|
141 |
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
|
|
|
142 |
value: 123456789.46,
|
|
|
143 |
expValue: "¥123,456,789.46",
|
|
|
144 |
comment: ""
|
|
|
145 |
},
|
|
|
146 |
{ attrs: {Currency: "CNY", lang: "zh-cn"},
|
|
|
147 |
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
|
|
|
148 |
value: -123456789.46,
|
|
|
149 |
expValue: "-¥123,456,789.46",
|
|
|
150 |
comment: ""
|
|
|
151 |
},
|
|
|
152 |
|
|
|
153 |
{ attrs: {Currency: "EUR", lang: "fr-fr"},
|
|
|
154 |
desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>",
|
|
|
155 |
value: 123456789.46,
|
|
|
156 |
expValue: "123 456 789,46 €",
|
|
|
157 |
comment: "Failed in IE. <a href='#cmt_1'>See #1.</a>"
|
|
|
158 |
},
|
|
|
159 |
{ attrs: {Currency: "EUR", lang: "fr-fr"},
|
|
|
160 |
desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>",
|
|
|
161 |
value: -123456789.46,
|
|
|
162 |
expValue: "-123 456 789,46 €",
|
|
|
163 |
comment: "Failed in IE. <a href='#cmt_1'>See #1.</a>"
|
|
|
164 |
},
|
|
|
165 |
|
|
|
166 |
{ attrs: {Currency: "JPY", lang: "ja-jp"},
|
|
|
167 |
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
|
|
|
168 |
value: 123456789,
|
|
|
169 |
expValue: "¥123,456,789",
|
|
|
170 |
comment: ""
|
|
|
171 |
},
|
|
|
172 |
{ attrs: {Currency: "JPY", lang: "ja-jp"},
|
|
|
173 |
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
|
|
|
174 |
value: -123456789,
|
|
|
175 |
expValue: "-¥123,456,789",
|
|
|
176 |
comment: ""
|
|
|
177 |
},
|
|
|
178 |
|
|
|
179 |
{ attrs: {Currency: "EGP", lang: "ar-eg"},
|
|
|
180 |
desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>",
|
|
|
181 |
value: 123456789.46,
|
|
|
182 |
expValue: "ج.م.\u200F 123٬456٬789٫46",
|
|
|
183 |
comment: "Failed in Firefox. <a href='#cmt_2'>See #2.</a>"
|
|
|
184 |
},
|
|
|
185 |
{ attrs: {Currency: "EGP", lang: "ar-eg"},
|
|
|
186 |
desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>",
|
|
|
187 |
value: -123456789.46,
|
|
|
188 |
expValue: "ج.م.\u200F 123٬456٬789٫46-",
|
|
|
189 |
comment: "Failed in Firefox. <a href='#cmt_2'>See #2.</a>"
|
|
|
190 |
},
|
|
|
191 |
|
|
|
192 |
{ attrs: {Currency: "EGP", lang: "ar-eg", constraints: "{localeDigit: true}"},
|
|
|
193 |
desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>",
|
|
|
194 |
value: 123456789.46,
|
|
|
195 |
expValue: "ج.م.\u200F ١٢٣\u066C٤٥٦\u066C٧٨٩\u066B٤٦",
|
|
|
196 |
comment: "<a href='#cmt_3'>See #3.</a> Failed in Firefox. <a href='#cmt_2'>See #2.</a>"
|
|
|
197 |
},
|
|
|
198 |
{ attrs: {Currency: "EGP", lang: "ar-eg", constraints: "{localeDigit: true}"},
|
|
|
199 |
desc: "Locale: <b>ar_EG</b> Currency: <b>EGP</b>",
|
|
|
200 |
value: -123456789.46,
|
|
|
201 |
expValue: "ج.م.\u200F ١٢٣\u066C٤٥٦\u066C٧٨٩\u066B٤٦-",
|
|
|
202 |
comment: "<a href='#cmt_3'>See #3.</a> Failed in Firefox. <a href='#cmt_2'>See #2.</a>"
|
|
|
203 |
}
|
|
|
204 |
]);
|
|
|
205 |
|
|
|
206 |
dojo.parser.parse();
|
|
|
207 |
|
|
|
208 |
})();
|
|
|
209 |
|
|
|
210 |
</script>
|
|
|
211 |
|
|
|
212 |
<h2 class="testTitle">Issues & Comments</h2>
|
|
|
213 |
<h3 class="testTitle"><a name="cmt_1">Issue #1<sup style="color:blue">Fixed</sup></a></h3>
|
|
|
214 |
<p>
|
|
|
215 |
Some browsers like FireFox have a bug on the non-breaking space character (U+00A0, <b>&nbsp;</b> or <b>&#160;</b> or
|
|
|
216 |
<b>&#xA0;</b> in HTML).
|
|
|
217 |
They always convert the NBSP character to a normal space (U+0020, <b>&#x20;</b> in HTML) automatically in the following circumstances:
|
|
|
218 |
</p>
|
|
|
219 |
<ul>
|
|
|
220 |
<li>Copy text from the page</li>
|
|
|
221 |
<li>Use <b>innerHTML</b> to get the content of a certain element</li>
|
|
|
222 |
<li>Use <b>value</b> to get an <b>INPUT</b> element's value</li>
|
|
|
223 |
</ul>
|
|
|
224 |
|
|
|
225 |
<p>
|
|
|
226 |
You cannot read a real NBSP character from an <b>INPUT</b> element on these browsers. It causes issues when some formatting data in CLDR
|
|
|
227 |
contains an NBSP character. For example,
|
|
|
228 |
</p>
|
|
|
229 |
<ul>
|
|
|
230 |
<li>Many locales like French use an NBSP character as a group separator in numbers</li>
|
|
|
231 |
<li>French and Finnish use NBSP characters in their percentage and currency format patterns respectively</li>
|
|
|
232 |
<li>Russian uses NBSP characters in their date format pattern (see <a href="test_validateDate.html">test_validateDate.html</a>)</li>
|
|
|
233 |
</ul>
|
|
|
234 |
|
|
|
235 |
<p>
|
|
|
236 |
So Dojo may generate formatted data with NBSP characters in it but cannot read NBSP charaters from user's input in some browser.
|
|
|
237 |
</p>
|
|
|
238 |
|
|
|
239 |
<h3 class="testTitle"><a name="cmt_2">Issue #2<sup style="color:blue">Fixed: the CLDR data generator should be fixed by adding code to convert U+200F to "\u200F" in nls JS files.</sup></a></h3>
|
|
|
240 |
<p>
|
|
|
241 |
Most Bidi currency symbols contain an LTR-MARK (U+200F) character at the very beginning.
|
|
|
242 |
But Firefox ignores it when it is not in any escaping form. This should be a bug of Firefox.
|
|
|
243 |
For example, click <a href="javascript:alert(''.indexOf('\u200F'))"><code>alert(''.indexOf('\u+200F'))</code></a> (there is a U+200F in the empty-looking string):
|
|
|
244 |
</p>
|
|
|
245 |
<ul>
|
|
|
246 |
<li>In Firefox, shows "-1" -- no U+200F found</li>
|
|
|
247 |
<li>In IE & Opera, shows "0" -- the U+200F is found</li>
|
|
|
248 |
</ul>
|
|
|
249 |
<p>
|
|
|
250 |
But if the U+200F is in some escaping form, Firefox will work as well as other browsers.
|
|
|
251 |
Click <a href="javascript:alert('\u200F'.indexOf('\u200F'))"><code>alert('\u200F'.indexOf('\u+200F'))</code></a> to see the same result both in Firefox and IE:
|
|
|
252 |
</p>
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
<h3 class="testTitle"><a name="cmt_3">Issue #3<sup style="color:blue">Fixed: added a "localeDigit" to the options</sup></a></h3>
|
|
|
256 |
<p>
|
|
|
257 |
Strictly speaking, the data conversion must support non-European number characters in some locales like Arabic and Hindi.
|
|
|
258 |
For example, ICU formats a number data into Indic number characters by default in the Arabic locale.
|
|
|
259 |
However, currently Dojo does not support this feature (Dojo uses the default number conversion of the browser).
|
|
|
260 |
</p>
|
|
|
261 |
|
|
|
262 |
</body>
|
|
|
263 |
</html>
|