1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>Test CurrencyTextBox</title>
8 <script type="text/javascript" src="../../../dojo/dojo.js"
9 djConfig="isDebug: true, extraLocale: ['zh-cn','fr-fr','ja-jp']"></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");
22 <script src="test_i18n.js"></script>
23 <script type="text/javascript">
24 dojo.addOnLoad(function(){
25 doh.register("t", getAllTestCases());
30 <style type="text/css">
31 @import "../../../dojo/resources/dojo.css";
32 @import "../../themes/tundra/tundra.css";
33 @import "../css/dijitTests.css";
36 background-color:#ddd;
40 background-color:#eee;
44 background-color:#fbfbfb;
47 border:1px solid #bfbfbf;
50 .dojoTitlePaneLabel label {
54 td {white-space:nowrap}
59 <h1 class="testTitle">Dijit TextBox Globalization Test for Currency</h1>
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> -->
64 Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", and "ja-jp"
65 and currencies CNY, EGP, EUR, JPY. If not, convert these CLDR data and put them there.
70 genFormatTestCases("Currency Format", "dijit.form.CurrencyTextBox", [
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",
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",
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 €",
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 €",
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",
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",
112 genValidateTestCases("Currency Validate", "dijit.form.CurrencyTextBox", [
114 { attrs: {Currency: "CNY", lang: "zh-cn"},
115 desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
117 expValue: "¥123,456,789.46",
120 { attrs: {Currency: "CNY", lang: "zh-cn"},
121 desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
122 value: -123456789.46,
123 expValue: "-¥123,456,789.46",
127 { attrs: {Currency: "EUR", lang: "fr-fr"},
128 desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>",
130 expValue: "123 456 789,46 €",
133 { attrs: {Currency: "EUR", lang: "fr-fr"},
134 desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>",
135 value: -123456789.46,
136 expValue: "-123 456 789,46 €",
140 { attrs: {Currency: "JPY", lang: "ja-jp"},
141 desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
143 expValue: "¥123,456,789",
146 { attrs: {Currency: "JPY", lang: "ja-jp"},
147 desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
149 expValue: "-¥123,456,789",
160 <h2 class="testTitle">Issues & Comments</h2>
161 <h3 class="testTitle"><a name="cmt_1">Issue #1<sup style="color:blue">Fixed</sup></a></h3>
163 Some browsers like FireFox have a bug on the non-breaking space character (U+00A0, <b>&nbsp;</b> or <b>&#160;</b> or
164 <b>&#xA0;</b> in HTML).
165 They always convert the NBSP character to a normal space (U+0020, <b>&#x20;</b> in HTML) automatically in the following circumstances:
168 <li>Copy text from the page</li>
169 <li>Use <b>innerHTML</b> to get the content of a certain element</li>
170 <li>Use <b>value</b> to get an <b>INPUT</b> element's value</li>
174 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
175 contains an NBSP character. For example,
178 <li>Many locales like French use an NBSP character as a group separator in numbers</li>
179 <li>French and Finnish use NBSP characters in their percentage and currency format patterns respectively</li>
183 So Dojo may generate formatted data with NBSP characters in it but cannot read NBSP charaters from user's input in some browser.
186 <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>
188 Most Bidi currency symbols contain an LTR-MARK (U+200F) character at the very beginning.
189 But Firefox ignores it when it is not in any escaping form. This should be a bug of Firefox.
190 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):
193 <li>In Firefox, shows "-1" -- no U+200F found</li>
194 <li>In IE & Opera, shows "0" -- the U+200F is found</li>
197 But if the U+200F is in some escaping form, Firefox will work as well as other browsers.
198 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:
202 <h3 class="testTitle"><a name="cmt_3">Issue #3<sup style="color:blue">Fixed: added a "localeDigit" to the options</sup></a></h3>
204 Strictly speaking, the data conversion must support non-European number characters in some locales like Arabic and Hindi.
205 For example, ICU formats a number data into Indic number characters by default in the Arabic locale.
206 However, currently Dojo does not support this feature (Dojo uses the default number conversion of the browser).