summaryrefslogtreecommitdiffstats
path: root/intl/strres/tests/unit/test_bug397093.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /intl/strres/tests/unit/test_bug397093.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/strres/tests/unit/test_bug397093.js')
-rw-r--r--intl/strres/tests/unit/test_bug397093.js39
1 files changed, 39 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 0000000000..a2bb1eb236
--- /dev/null
+++ b/intl/strres/tests/unit/test_bug397093.js
@@ -0,0 +1,39 @@
+/* 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 = Services.strings;
+ var bundleURI = Services.io.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) {}
+ Assert.equal(bundle_ascii, value_ascii);
+
+ try {
+ bundle_utf8 = bundle.GetStringFromName(name_utf8);
+ } catch (e) {}
+ Assert.equal(bundle_utf8, value_utf8);
+
+ try {
+ bundle_latin1 = bundle.GetStringFromName(name_latin1);
+ } catch (e) {}
+ Assert.equal(bundle_latin1, value_latin1);
+}