summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/unit/test_bug813245.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 /dom/plugins/test/unit/test_bug813245.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 'dom/plugins/test/unit/test_bug813245.js')
-rw-r--r--dom/plugins/test/unit/test_bug813245.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/dom/plugins/test/unit/test_bug813245.js b/dom/plugins/test/unit/test_bug813245.js
new file mode 100644
index 000000000..069e4a014
--- /dev/null
+++ b/dom/plugins/test/unit/test_bug813245.js
@@ -0,0 +1,87 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+// Plugin registry uses different field delimeters on different platforms
+var DELIM = mozinfo.os == "win" ? "|" : ":";
+
+var gProfD = do_get_profile_startup();
+
+// Writes out some plugin registry to the profile
+function write_registry(version, info) {
+ let runtime = Cc["@mozilla.org/xre/runtime;1"].getService(Ci.nsIXULRuntime);
+
+ var header = "Generated File. Do not edit.\n\n";
+ header += "[HEADER]\n";
+ header += "Version" + DELIM + version + DELIM + "$\n";
+ header += "Arch" + DELIM + runtime.XPCOMABI + DELIM + "$\n";
+ header += "\n";
+ header += "[PLUGINS]\n";
+
+ var registry = gProfD.clone();
+ registry.append("pluginreg.dat");
+ var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
+ .createInstance(Components.interfaces.nsIFileOutputStream);
+ // write, create, truncate
+ foStream.init(registry, 0x02 | 0x08 | 0x20, 0o666, 0);
+
+ var charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
+ var os = Cc["@mozilla.org/intl/converter-output-stream;1"].
+ createInstance(Ci.nsIConverterOutputStream);
+ os.init(foStream, charset, 0, 0x0000);
+
+ os.writeString(header);
+ os.writeString(info);
+ os.close();
+}
+
+function run_test() {
+ allow_all_plugins();
+ var plugin = get_test_plugintag();
+ do_check_true(plugin == null);
+
+ var file = get_test_plugin();
+ if (!file) {
+ do_throw("Plugin library not found");
+ }
+
+ // write plugin registry data
+ let registry = "";
+
+ if (gIsOSX) {
+ registry += file.leafName + DELIM + "$\n";
+ registry += file.path + DELIM + "$\n";
+ } else {
+ registry += file.path + DELIM + "$\n";
+ registry += DELIM + "$\n";
+ }
+ registry += "0.0.0.0" + DELIM + "$\n";
+ registry += "16725225600" + DELIM + "0" + DELIM + "5" + DELIM + "$\n";
+ registry += "Plug-in for testing purposes." + DELIM + "$\n";
+ registry += "Test Plug-in" + DELIM + "$\n";
+ registry += "999999999999999999999999999999999999999999999999|0|5|$\n";
+ registry += "0" + DELIM + "application/x-test" + DELIM + "Test mimetype" +
+ DELIM + "tst" + DELIM + "$\n";
+
+ registry += "\n";
+ registry += "[INVALID]\n";
+ registry += "\n";
+ write_registry("0.15", registry);
+
+ // Initialise profile folder
+ do_get_profile();
+
+ var plugin = get_test_plugintag();
+ if (!plugin)
+ do_throw("Plugin tag not found");
+
+ // The plugin registry should have been rejected.
+ // If not, the test plugin version would be 0.0.0.0
+ do_check_eq(plugin.version, "1.0.0.0");
+
+ // Clean up
+ Services.prefs.clearUserPref("plugin.importedState");
+}