Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 */
7 const name_ascii = "asciiProperty";
8 const value_ascii = "";
10 const name_utf8 = "utf8Property";
11 const value_utf8 = "";
13 const name_latin1 = "latin1";
14 const value_latin1 = "";
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"));
25 var bundle = StringBundle.createBundle(bundleURI.spec);
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);
33 try {
34 bundle_utf8 = bundle.GetStringFromName(name_utf8);
35 } catch(e) {}
36 do_check_eq(bundle_utf8, value_utf8);
38 try {
39 bundle_latin1 = bundle.GetStringFromName(name_latin1);
40 } catch(e) {}
41 do_check_eq(bundle_latin1, value_latin1);
42 }