summaryrefslogtreecommitdiffstats
path: root/intl/strres/tests/unit/test_bug397093.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /intl/strres/tests/unit/test_bug397093.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'intl/strres/tests/unit/test_bug397093.js')
-rw-r--r--intl/strres/tests/unit/test_bug397093.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/intl/strres/tests/unit/test_bug397093.js b/intl/strres/tests/unit/test_bug397093.js
new file mode 100644
index 000000000..36ba3bb14
--- /dev/null
+++ b/intl/strres/tests/unit/test_bug397093.js
@@ -0,0 +1,43 @@
+/* Tests getting properties from string bundles with incorrect encoding.
+ * The string bundle contains one ascii property, one UTF-8 and one Latin-1.
+ * Expected behaviour is that the whole string bundle should be rejected and
+ * all GetStringFromName calls should fail.
+ */
+
+const name_ascii = "asciiProperty";
+const value_ascii = "";
+
+const name_utf8 = "utf8Property";
+const value_utf8 = "";
+
+const name_latin1 = "latin1";
+const value_latin1 = "";
+
+
+function run_test() {
+ var StringBundle =
+ Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService);
+ var ios = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+ var bundleURI = ios.newFileURI(do_get_file("397093.properties"));
+
+ var bundle = StringBundle.createBundle(bundleURI.spec);
+
+ var bundle_ascii="", bundle_utf8="", bundle_latin1="";
+ try {
+ bundle_ascii = bundle.GetStringFromName(name_ascii);
+ } catch(e) {}
+ do_check_eq(bundle_ascii, value_ascii);
+
+ try {
+ bundle_utf8 = bundle.GetStringFromName(name_utf8);
+ } catch(e) {}
+ do_check_eq(bundle_utf8, value_utf8);
+
+ try {
+ bundle_latin1 = bundle.GetStringFromName(name_latin1);
+ } catch(e) {}
+ do_check_eq(bundle_latin1, value_latin1);
+}
+