diff options
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js index 1512a7f92..623a6a14a 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js @@ -4,11 +4,10 @@ */ const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul"; -var Ci = Components.interfaces; -var Cu = Components.utils; +const Ci = Components.interfaces; +const Cu = Components.utils; Cu.import("resource://testing-common/httpd.js"); -Cu.import("resource://testing-common/MockRegistrar.jsm"); var ADDONS = [{ id: "test_bug449027_1@tests.mozilla.org", @@ -250,15 +249,23 @@ var PluginHost = { } } +var PluginHostFactory = { + createInstance: function (outer, iid) { + if (outer != null) + throw Components.results.NS_ERROR_NO_AGGREGATION; + return PluginHost.QueryInterface(iid); + } +}; + // Don't need the full interface, attempts to call other methods will just // throw which is just fine var WindowWatcher = { - openWindow: function(parent, url, name, features, args) { + openWindow: function(parent, url, name, features, arguments) { // Should be called to list the newly blocklisted items do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG); do_check_neq(gCallback, null); - args = args.wrappedJSObject; + var args = arguments.wrappedJSObject; gNewBlocks = []; var list = args.list; @@ -278,8 +285,20 @@ var WindowWatcher = { } } -MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost); -MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher); +var WindowWatcherFactory = { + createInstance: function createInstance(outer, iid) { + if (outer != null) + throw Components.results.NS_ERROR_NO_AGGREGATION; + return WindowWatcher.QueryInterface(iid); + } +}; +var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); +registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"), + "Fake Plugin Host", + "@mozilla.org/plugin/host;1", PluginHostFactory); +registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), + "Fake Window Watcher", + "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory); function create_addon(addon) { var installrdf = "<?xml version=\"1.0\"?>\n" + @@ -303,10 +322,10 @@ function create_addon(addon) { target.append("extensions"); target.append(addon.id); target.append("install.rdf"); - target.create(target.NORMAL_FILE_TYPE, 0o644); + target.create(target.NORMAL_FILE_TYPE, 0644); var stream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance(Ci.nsIFileOutputStream); - stream.init(target, 0x04 | 0x08 | 0x20, 0o664, 0); // write, create, truncate + stream.init(target, 0x04 | 0x08 | 0x20, 0664, 0); // write, create, truncate stream.write(installrdf, installrdf.length); stream.close(); } @@ -317,7 +336,7 @@ function create_addon(addon) { * the newly blocked items compared to the previous test. */ function check_state(test, lastTest, callback) { - AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) { + AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) { for (var i = 0; i < ADDONS.length; i++) { var blocked = addons[i].blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED; if (blocked != ADDONS[i][test]) @@ -386,13 +405,13 @@ function run_test() { function check_test_pt1() { dump("Checking pt 1\n"); - AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) { + AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) { for (var i = 0; i < ADDONS.length; i++) { if (!addons[i]) do_throw("Addon " + (i + 1) + " did not get installed correctly"); } - do_execute_soon(function checkstate1() { check_state("start", null, run_test_pt2); }); + do_execute_soon(function checkstate1() {check_state("start", null, run_test_pt2);}); }); } |