michael@0: /* Tests getting properties from string bundles with incorrect encoding. michael@0: * The string bundle contains one ascii property, one UTF-8 and one Latin-1. michael@0: * Expected behaviour is that the whole string bundle should be rejected and michael@0: * all GetStringFromName calls should fail. michael@0: */ michael@0: michael@0: const name_ascii = "asciiProperty"; michael@0: const value_ascii = ""; michael@0: michael@0: const name_utf8 = "utf8Property"; michael@0: const value_utf8 = ""; michael@0: michael@0: const name_latin1 = "latin1"; michael@0: const value_latin1 = ""; michael@0: michael@0: michael@0: function run_test() { michael@0: var StringBundle = michael@0: Components.classes["@mozilla.org/intl/stringbundle;1"] michael@0: .getService(Components.interfaces.nsIStringBundleService); michael@0: var ios = Components.classes["@mozilla.org/network/io-service;1"] michael@0: .getService(Components.interfaces.nsIIOService); michael@0: var bundleURI = ios.newFileURI(do_get_file("397093.properties")); michael@0: michael@0: var bundle = StringBundle.createBundle(bundleURI.spec); michael@0: michael@0: var bundle_ascii="", bundle_utf8="", bundle_latin1=""; michael@0: try { michael@0: bundle_ascii = bundle.GetStringFromName(name_ascii); michael@0: } catch(e) {} michael@0: do_check_eq(bundle_ascii, value_ascii); michael@0: michael@0: try { michael@0: bundle_utf8 = bundle.GetStringFromName(name_utf8); michael@0: } catch(e) {} michael@0: do_check_eq(bundle_utf8, value_utf8); michael@0: michael@0: try { michael@0: bundle_latin1 = bundle.GetStringFromName(name_latin1); michael@0: } catch(e) {} michael@0: do_check_eq(bundle_latin1, value_latin1); michael@0: } michael@0: