Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 7 | |
michael@0 | 8 | // Plugin registry uses different field delimeters on different platforms |
michael@0 | 9 | var DELIM = ":"; |
michael@0 | 10 | if ("@mozilla.org/windows-registry-key;1" in Components.classes) |
michael@0 | 11 | DELIM = "|"; |
michael@0 | 12 | |
michael@0 | 13 | var gProfD = do_get_profile_startup(); |
michael@0 | 14 | var gDirSvc = Cc["@mozilla.org/file/directory_service;1"]. |
michael@0 | 15 | getService(Ci.nsIProperties); |
michael@0 | 16 | |
michael@0 | 17 | // Writes out some plugin registry to the profile |
michael@0 | 18 | function write_registry(version, info) { |
michael@0 | 19 | var header = "Generated File. Do not edit.\n\n"; |
michael@0 | 20 | header += "[HEADER]\n"; |
michael@0 | 21 | header += "Version" + DELIM + version + DELIM + "$\n\n"; |
michael@0 | 22 | header += "[PLUGINS]\n"; |
michael@0 | 23 | |
michael@0 | 24 | var registry = gProfD.clone(); |
michael@0 | 25 | registry.append("pluginreg.dat"); |
michael@0 | 26 | var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"] |
michael@0 | 27 | .createInstance(Components.interfaces.nsIFileOutputStream); |
michael@0 | 28 | // write, create, truncate |
michael@0 | 29 | foStream.init(registry, 0x02 | 0x08 | 0x20, 0666, 0); |
michael@0 | 30 | |
michael@0 | 31 | var charset = "UTF-8"; // Can be any character encoding name that Mozilla supports |
michael@0 | 32 | var os = Cc["@mozilla.org/intl/converter-output-stream;1"]. |
michael@0 | 33 | createInstance(Ci.nsIConverterOutputStream); |
michael@0 | 34 | os.init(foStream, charset, 0, 0x0000); |
michael@0 | 35 | |
michael@0 | 36 | os.writeString(header); |
michael@0 | 37 | os.writeString(info); |
michael@0 | 38 | os.close(); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function run_test() { |
michael@0 | 42 | var plugin = get_test_plugintag(); |
michael@0 | 43 | do_check_true(plugin == null); |
michael@0 | 44 | |
michael@0 | 45 | var file = get_test_plugin(); |
michael@0 | 46 | if (!file) |
michael@0 | 47 | do_throw("Plugin library not found"); |
michael@0 | 48 | |
michael@0 | 49 | // Write out a 0.9 version registry that marks the test plugin as disabled |
michael@0 | 50 | var registry = ""; |
michael@0 | 51 | if (gIsOSX) { |
michael@0 | 52 | registry += file.leafName + DELIM + "$\n"; |
michael@0 | 53 | registry += file.path + DELIM + "$\n"; |
michael@0 | 54 | } else { |
michael@0 | 55 | registry += file.path + DELIM + "$\n"; |
michael@0 | 56 | registry += DELIM + "$\n"; |
michael@0 | 57 | } |
michael@0 | 58 | registry += file.lastModifiedTime + DELIM + "0" + DELIM + "0" + DELIM + "$\n"; |
michael@0 | 59 | registry += "Plug-in for testing purposes.\u2122 " + |
michael@0 | 60 | "(\u0939\u093f\u0928\u094d\u0926\u0940 " + |
michael@0 | 61 | "\u4e2d\u6587 " + |
michael@0 | 62 | "\u0627\u0644\u0639\u0631\u0628\u064a\u0629)" + |
michael@0 | 63 | DELIM + "$\n"; |
michael@0 | 64 | registry += "Test Plug-in" + DELIM + "$\n"; |
michael@0 | 65 | registry += "1\n"; |
michael@0 | 66 | registry += "0" + DELIM + "application/x-test" + DELIM + "Test mimetype" + |
michael@0 | 67 | DELIM + "tst" + DELIM + "$\n"; |
michael@0 | 68 | write_registry("0.9", registry); |
michael@0 | 69 | |
michael@0 | 70 | // Initialise profile folder |
michael@0 | 71 | do_get_profile(); |
michael@0 | 72 | |
michael@0 | 73 | plugin = get_test_plugintag(); |
michael@0 | 74 | if (!plugin) |
michael@0 | 75 | do_throw("Plugin tag not found"); |
michael@0 | 76 | |
michael@0 | 77 | // If the plugin was not rescanned then this version will not be correct |
michael@0 | 78 | do_check_eq(plugin.version, "1.0.0.0"); |
michael@0 | 79 | do_check_eq(plugin.description, |
michael@0 | 80 | "Plug-in for testing purposes.\u2122 " + |
michael@0 | 81 | "(\u0939\u093f\u0928\u094d\u0926\u0940 " + |
michael@0 | 82 | "\u4e2d\u6587 " + |
michael@0 | 83 | "\u0627\u0644\u0639\u0631\u0628\u064a\u0629)"); |
michael@0 | 84 | // If the plugin registry was not read then the plugin will not be disabled |
michael@0 | 85 | do_check_true(plugin.disabled); |
michael@0 | 86 | do_check_false(plugin.blocklisted); |
michael@0 | 87 | |
michael@0 | 88 | // Clean up |
michael@0 | 89 | Services.prefs.clearUserPref("plugin.importedState"); |
michael@0 | 90 | } |