diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:49:12 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:49:12 -0500 |
commit | 4fb11cd5966461bccc3ed1599b808237be6b0de9 (patch) | |
tree | d7f0ccd49cebb3544d52635ff1bd6ed4d763823f /toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js | |
parent | f164d9124708b50789dbb6959e1de96cc5697c48 (diff) | |
download | UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.gz UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.lz UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.xz UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.zip |
Move WebExtensions enabled Add-ons Manager
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js deleted file mode 100644 index e22ab87c9..000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js +++ /dev/null @@ -1,155 +0,0 @@ -/* 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/. - */ - -var addonIDs = ["test_bug393285_1@tests.mozilla.org", - "test_bug393285_2@tests.mozilla.org", - "test_bug393285_3a@tests.mozilla.org", - "test_bug393285_4@tests.mozilla.org"]; - -var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; - -const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul"; - -Cu.import("resource://testing-common/httpd.js"); -Cu.import("resource://testing-common/MockRegistrar.jsm"); -var testserver = new HttpServer(); -testserver.start(-1); -gPort = testserver.identity.primaryPort; - -// register static files with server and interpolate port numbers in them -mapFile("/data/test_bug393285.xml", testserver); - -const profileDir = gProfD.clone(); -profileDir.append("extensions"); - -// A window watcher to deal with the blocklist UI dialog. -var WindowWatcher = { - openWindow: function(parent, url, name, features, args) { - // Should be called to list the newly blocklisted items - do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG); - - // Simulate auto-disabling any softblocks - var list = args.wrappedJSObject.list; - list.forEach(function(aItem) { - if (!aItem.blocked) - aItem.disable = true; - }); - - // run the code after the blocklist is closed - Services.obs.notifyObservers(null, "addon-blocklist-closed", null); - - }, - - QueryInterface: function(iid) { - if (iid.equals(Ci.nsIWindowWatcher) - || iid.equals(Ci.nsISupports)) - return this; - - throw Cr.NS_ERROR_NO_INTERFACE; - } -}; - -MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher); - -function load_blocklist(aFile, aCallback) { - Services.obs.addObserver(function() { - Services.obs.removeObserver(arguments.callee, "blocklist-updated"); - - do_execute_soon(aCallback); - }, "blocklist-updated", false); - - Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + - gPort + "/data/" + aFile); - var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. - getService(Ci.nsITimerCallback); - blocklist.notify(null); -} - - -function end_test() { - testserver.stop(do_test_finished); -} - -function run_test() { - do_test_pending(); - - createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); - - writeInstallRDFForExtension({ - id: "test_bug393285_1@tests.mozilla.org", - name: "extension 1", - version: "1.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "1", - maxVersion: "3" - }] - }, profileDir); - - - writeInstallRDFForExtension({ - id: "test_bug393285_2@tests.mozilla.org", - name: "extension 2", - version: "1.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "1", - maxVersion: "3" - }] - }, profileDir); - - writeInstallRDFForExtension({ - id: "test_bug393285_3a@tests.mozilla.org", - name: "extension 3a", - version: "1.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "1", - maxVersion: "3" - }] - }, profileDir); - - writeInstallRDFForExtension({ - id: "test_bug393285_4@tests.mozilla.org", - name: "extension 4", - version: "1.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "1", - maxVersion: "3" - }] - }, profileDir); - - startupManager(); - - AddonManager.getAddonsByIDs(addonIDs, function(addons) { - for (let addon of addons) { - do_check_eq(addon.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); - } - run_test_1(); - }); -} - -function run_test_1() { - load_blocklist("test_bug393285.xml", function() { - restartManager(); - - var blocklist = Cc["@mozilla.org/extensions/blocklist;1"] - .getService(Ci.nsIBlocklistService); - - AddonManager.getAddonsByIDs(addonIDs, - function([a1, a2, a3, a4]) { - // No info in blocklist, shouldn't be blocked - do_check_false(blocklist.isAddonBlocklisted(a1, null, null)); - - // All these should be blocklisted for the current app. - do_check_true(blocklist.isAddonBlocklisted(a2, null, null)); - do_check_true(blocklist.isAddonBlocklisted(a3, null, null)); - do_check_true(blocklist.isAddonBlocklisted(a4, null, null)); - - end_test(); - }); - }); -} |