| |
1 /* Tests getting properties from string bundles with incorrect encoding. |
| |
2 * The string bundle contains one ascii property, one UTF-8 and one Latin-1. |
| |
3 * Expected behaviour is that the whole string bundle should be rejected and |
| |
4 * all GetStringFromName calls should fail. |
| |
5 */ |
| |
6 |
| |
7 const name_ascii = "asciiProperty"; |
| |
8 const value_ascii = ""; |
| |
9 |
| |
10 const name_utf8 = "utf8Property"; |
| |
11 const value_utf8 = ""; |
| |
12 |
| |
13 const name_latin1 = "latin1"; |
| |
14 const value_latin1 = ""; |
| |
15 |
| |
16 |
| |
17 function run_test() { |
| |
18 var StringBundle = |
| |
19 Components.classes["@mozilla.org/intl/stringbundle;1"] |
| |
20 .getService(Components.interfaces.nsIStringBundleService); |
| |
21 var ios = Components.classes["@mozilla.org/network/io-service;1"] |
| |
22 .getService(Components.interfaces.nsIIOService); |
| |
23 var bundleURI = ios.newFileURI(do_get_file("397093.properties")); |
| |
24 |
| |
25 var bundle = StringBundle.createBundle(bundleURI.spec); |
| |
26 |
| |
27 var bundle_ascii="", bundle_utf8="", bundle_latin1=""; |
| |
28 try { |
| |
29 bundle_ascii = bundle.GetStringFromName(name_ascii); |
| |
30 } catch(e) {} |
| |
31 do_check_eq(bundle_ascii, value_ascii); |
| |
32 |
| |
33 try { |
| |
34 bundle_utf8 = bundle.GetStringFromName(name_utf8); |
| |
35 } catch(e) {} |
| |
36 do_check_eq(bundle_utf8, value_utf8); |
| |
37 |
| |
38 try { |
| |
39 bundle_latin1 = bundle.GetStringFromName(name_latin1); |
| |
40 } catch(e) {} |
| |
41 do_check_eq(bundle_latin1, value_latin1); |
| |
42 } |
| |
43 |