michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: // Plugin registry uses different field delimeters on different platforms michael@0: var DELIM = ":"; michael@0: if ("@mozilla.org/windows-registry-key;1" in Components.classes) michael@0: DELIM = "|"; michael@0: michael@0: var gProfD = do_get_profile_startup(); michael@0: var gDirSvc = Cc["@mozilla.org/file/directory_service;1"]. michael@0: getService(Ci.nsIProperties); michael@0: michael@0: // Writes out some plugin registry to the profile michael@0: function write_registry(version, info) { michael@0: var header = "Generated File. Do not edit.\n\n"; michael@0: header += "[HEADER]\n"; michael@0: header += "Version" + DELIM + version + DELIM + "$\n\n"; michael@0: header += "[PLUGINS]\n"; michael@0: michael@0: var registry = gProfD.clone(); michael@0: registry.append("pluginreg.dat"); michael@0: var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"] michael@0: .createInstance(Components.interfaces.nsIFileOutputStream); michael@0: // write, create, truncate michael@0: foStream.init(registry, 0x02 | 0x08 | 0x20, 0666, 0); michael@0: michael@0: var charset = "UTF-8"; // Can be any character encoding name that Mozilla supports michael@0: var os = Cc["@mozilla.org/intl/converter-output-stream;1"]. michael@0: createInstance(Ci.nsIConverterOutputStream); michael@0: os.init(foStream, charset, 0, 0x0000); michael@0: michael@0: os.writeString(header); michael@0: os.writeString(info); michael@0: os.close(); michael@0: } michael@0: michael@0: function run_test() { michael@0: var plugin = get_test_plugintag(); michael@0: do_check_true(plugin == null); michael@0: michael@0: var file = get_test_plugin(); michael@0: if (!file) michael@0: do_throw("Plugin library not found"); michael@0: michael@0: // Write out a 0.9 version registry that marks the test plugin as disabled michael@0: var registry = ""; michael@0: if (gIsOSX) { michael@0: registry += file.leafName + DELIM + "$\n"; michael@0: registry += file.path + DELIM + "$\n"; michael@0: } else { michael@0: registry += file.path + DELIM + "$\n"; michael@0: registry += DELIM + "$\n"; michael@0: } michael@0: registry += file.lastModifiedTime + DELIM + "0" + DELIM + "0" + DELIM + "$\n"; michael@0: registry += "Plug-in for testing purposes.\u2122 " + michael@0: "(\u0939\u093f\u0928\u094d\u0926\u0940 " + michael@0: "\u4e2d\u6587 " + michael@0: "\u0627\u0644\u0639\u0631\u0628\u064a\u0629)" + michael@0: DELIM + "$\n"; michael@0: registry += "Test Plug-in" + DELIM + "$\n"; michael@0: registry += "1\n"; michael@0: registry += "0" + DELIM + "application/x-test" + DELIM + "Test mimetype" + michael@0: DELIM + "tst" + DELIM + "$\n"; michael@0: write_registry("0.9", registry); michael@0: michael@0: // Initialise profile folder michael@0: do_get_profile(); michael@0: michael@0: plugin = get_test_plugintag(); michael@0: if (!plugin) michael@0: do_throw("Plugin tag not found"); michael@0: michael@0: // If the plugin was not rescanned then this version will not be correct michael@0: do_check_eq(plugin.version, "1.0.0.0"); michael@0: do_check_eq(plugin.description, michael@0: "Plug-in for testing purposes.\u2122 " + michael@0: "(\u0939\u093f\u0928\u094d\u0926\u0940 " + michael@0: "\u4e2d\u6587 " + michael@0: "\u0627\u0644\u0639\u0631\u0628\u064a\u0629)"); michael@0: // If the plugin registry was not read then the plugin will not be disabled michael@0: do_check_true(plugin.disabled); michael@0: do_check_false(plugin.blocklisted); michael@0: michael@0: // Clean up michael@0: Services.prefs.clearUserPref("plugin.importedState"); michael@0: }