michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Checks that changes that cause an add-on to become unblocked or blocked have michael@0: // the right effect michael@0: michael@0: // The tests follow a mostly common pattern. First they start with the add-ons michael@0: // unblocked, then they make a change that causes the add-ons to become blocked michael@0: // then they make a similar change that keeps the add-ons blocked then they make michael@0: // a change that unblocks the add-ons. Some tests skip the initial part and michael@0: // start with add-ons detected as blocked. michael@0: michael@0: // softblock1 is enabled/disabled by the blocklist changes so its softDisabled michael@0: // property should always match its userDisabled property michael@0: michael@0: // softblock2 gets manually enabled then disabled after it becomes blocked so michael@0: // its softDisabled property should never become true after that michael@0: michael@0: // softblock3 does the same as softblock2 however it remains disabled michael@0: michael@0: // softblock4 is disabled while unblocked and so should never have softDisabled michael@0: // set to true and stay userDisabled. This add-on is not used in tests that michael@0: // start with add-ons blocked as it would be identical to softblock3 michael@0: michael@0: // softblock5 is a theme. Currently themes just get disabled when they become michael@0: // softblocked and have to be manually re-enabled if they become completely michael@0: // unblocked (bug 657520) michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: const Cr = Components.results; michael@0: michael@0: const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul"; michael@0: michael@0: Cu.import("resource://gre/modules/NetUtil.jsm"); michael@0: michael@0: // Allow insecure updates michael@0: Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false) michael@0: michael@0: Cu.import("resource://testing-common/httpd.js"); michael@0: var testserver = new HttpServer(); michael@0: testserver.start(-1); michael@0: gPort = testserver.identity.primaryPort; michael@0: michael@0: // register static files with server and interpolate port numbers in them michael@0: mapFile("/data/blocklistchange/addon_update1.rdf", testserver); michael@0: mapFile("/data/blocklistchange/addon_update2.rdf", testserver); michael@0: mapFile("/data/blocklistchange/addon_update3.rdf", testserver); michael@0: mapFile("/data/blocklistchange/addon_change.xml", testserver); michael@0: mapFile("/data/blocklistchange/app_update.xml", testserver); michael@0: mapFile("/data/blocklistchange/blocklist_update1.xml", testserver); michael@0: mapFile("/data/blocklistchange/blocklist_update2.xml", testserver); michael@0: mapFile("/data/blocklistchange/manual_update.xml", testserver); michael@0: michael@0: testserver.registerDirectory("/addons/", do_get_file("addons")); michael@0: michael@0: michael@0: var default_theme = { michael@0: id: "default@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Softblocked add-on", michael@0: internalName: "classic/1.0", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock1_1 = { michael@0: id: "softblock1@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock1_2 = { michael@0: id: "softblock1@tests.mozilla.org", michael@0: version: "2.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock1_3 = { michael@0: id: "softblock1@tests.mozilla.org", michael@0: version: "3.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock2_1 = { michael@0: id: "softblock2@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock2_2 = { michael@0: id: "softblock2@tests.mozilla.org", michael@0: version: "2.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock2_3 = { michael@0: id: "softblock2@tests.mozilla.org", michael@0: version: "3.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock3_1 = { michael@0: id: "softblock3@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock3_2 = { michael@0: id: "softblock3@tests.mozilla.org", michael@0: version: "2.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock3_3 = { michael@0: id: "softblock3@tests.mozilla.org", michael@0: version: "3.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock4_1 = { michael@0: id: "softblock4@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock4_2 = { michael@0: id: "softblock4@tests.mozilla.org", michael@0: version: "2.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock4_3 = { michael@0: id: "softblock4@tests.mozilla.org", michael@0: version: "3.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock5_1 = { michael@0: id: "softblock5@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", michael@0: internalName: "test/1.0", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock5_2 = { michael@0: id: "softblock5@tests.mozilla.org", michael@0: version: "2.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", michael@0: internalName: "test/1.0", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var softblock5_3 = { michael@0: id: "softblock5@tests.mozilla.org", michael@0: version: "3.0", michael@0: name: "Softblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", michael@0: internalName: "test/1.0", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var hardblock_1 = { michael@0: id: "hardblock@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Hardblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var hardblock_2 = { michael@0: id: "hardblock@tests.mozilla.org", michael@0: version: "2.0", michael@0: name: "Hardblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var hardblock_3 = { michael@0: id: "hardblock@tests.mozilla.org", michael@0: version: "3.0", michael@0: name: "Hardblocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var regexpblock_1 = { michael@0: id: "regexpblock@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "RegExp-blocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var regexpblock_2 = { michael@0: id: "regexpblock@tests.mozilla.org", michael@0: version: "2.0", michael@0: name: "RegExp-blocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: var regexpblock_3 = { michael@0: id: "regexpblock@tests.mozilla.org", michael@0: version: "3.0", michael@0: name: "RegExp-blocked add-on", michael@0: updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }; michael@0: michael@0: const ADDON_IDS = ["softblock1@tests.mozilla.org", michael@0: "softblock2@tests.mozilla.org", michael@0: "softblock3@tests.mozilla.org", michael@0: "softblock4@tests.mozilla.org", michael@0: "softblock5@tests.mozilla.org", michael@0: "hardblock@tests.mozilla.org", michael@0: "regexpblock@tests.mozilla.org"]; michael@0: michael@0: // Don't need the full interface, attempts to call other methods will just michael@0: // throw which is just fine michael@0: var WindowWatcher = { michael@0: openWindow: function(parent, url, name, features, openArgs) { michael@0: // Should be called to list the newly blocklisted items michael@0: do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG); michael@0: michael@0: // Simulate auto-disabling any softblocks michael@0: var list = openArgs.wrappedJSObject.list; michael@0: list.forEach(function(aItem) { michael@0: if (!aItem.blocked) michael@0: aItem.disable = true; michael@0: }); michael@0: michael@0: //run the code after the blocklist is closed michael@0: Services.obs.notifyObservers(null, "addon-blocklist-closed", null); michael@0: michael@0: }, michael@0: michael@0: QueryInterface: function(iid) { michael@0: if (iid.equals(Ci.nsIWindowWatcher) michael@0: || iid.equals(Ci.nsISupports)) michael@0: return this; michael@0: michael@0: throw Cr.NS_ERROR_NO_INTERFACE; michael@0: } michael@0: }; michael@0: michael@0: var WindowWatcherFactory = { michael@0: createInstance: function createInstance(outer, iid) { michael@0: if (outer != null) michael@0: throw Components.results.NS_ERROR_NO_AGGREGATION; michael@0: return WindowWatcher.QueryInterface(iid); michael@0: } michael@0: }; michael@0: michael@0: var InstallConfirm = { michael@0: confirm: function(aWindow, aUrl, aInstalls, aInstallCount) { michael@0: aInstalls.forEach(function(aInstall) { michael@0: aInstall.install(); michael@0: }); michael@0: }, michael@0: michael@0: QueryInterface: function(iid) { michael@0: if (iid.equals(Ci.amIWebInstallPrompt) michael@0: || iid.equals(Ci.nsISupports)) michael@0: return this; michael@0: michael@0: throw Cr.NS_ERROR_NO_INTERFACE; michael@0: } michael@0: }; michael@0: michael@0: var InstallConfirmFactory = { michael@0: createInstance: function createInstance(outer, iid) { michael@0: if (outer != null) michael@0: throw Components.results.NS_ERROR_NO_AGGREGATION; michael@0: return InstallConfirm.QueryInterface(iid); michael@0: } michael@0: }; michael@0: michael@0: var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); michael@0: registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), michael@0: "Fake Window Watcher", michael@0: "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory); michael@0: registrar.registerFactory(Components.ID("{f0863905-4dde-42e2-991c-2dc8209bc9ca}"), michael@0: "Fake Install Prompt", michael@0: "@mozilla.org/addons/web-install-prompt;1", InstallConfirmFactory); michael@0: michael@0: const profileDir = gProfD.clone(); michael@0: profileDir.append("extensions"); michael@0: michael@0: function load_blocklist(aFile, aCallback) { michael@0: Services.obs.addObserver(function() { michael@0: Services.obs.removeObserver(arguments.callee, "blocklist-updated"); michael@0: michael@0: do_execute_soon(aCallback); michael@0: }, "blocklist-updated", false); michael@0: michael@0: Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/blocklistchange/" + aFile); michael@0: var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. michael@0: getService(Ci.nsITimerCallback); michael@0: blocklist.notify(null); michael@0: } michael@0: michael@0: // Does a background update check for add-ons and waits for any started installs michael@0: // to complete michael@0: function background_update(aCallback) { michael@0: var installCount = 0; michael@0: var backgroundCheckCompleted = false; michael@0: michael@0: AddonManager.addInstallListener({ michael@0: onNewInstall: function(aInstall) { michael@0: installCount++; michael@0: }, michael@0: michael@0: onInstallEnded: function(aInstall) { michael@0: installCount--; michael@0: // Wait until all started installs have completed michael@0: if (installCount) michael@0: return; michael@0: michael@0: AddonManager.removeInstallListener(this); michael@0: michael@0: // If the background check hasn't yet completed then let that call the michael@0: // callback when it is done michael@0: if (!backgroundCheckCompleted) michael@0: return; michael@0: michael@0: do_execute_soon(aCallback); michael@0: } michael@0: }); michael@0: michael@0: Services.obs.addObserver(function() { michael@0: Services.obs.removeObserver(arguments.callee, "addons-background-update-complete"); michael@0: backgroundCheckCompleted = true; michael@0: michael@0: // If any new installs have started then we'll call the callback once they michael@0: // are completed michael@0: if (installCount) michael@0: return; michael@0: michael@0: do_execute_soon(aCallback); michael@0: }, "addons-background-update-complete", false); michael@0: michael@0: AddonManagerPrivate.backgroundUpdateCheck(); michael@0: } michael@0: michael@0: // Manually updates the test add-ons to the given version michael@0: function manual_update(aVersion, aCallback) { michael@0: var installs = []; michael@0: AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft1_" + aVersion + ".xpi", michael@0: function(aInstall) { michael@0: installs.push(aInstall); michael@0: AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft2_" + aVersion + ".xpi", michael@0: function(aInstall) { michael@0: installs.push(aInstall); michael@0: AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft3_" + aVersion + ".xpi", michael@0: function(aInstall) { michael@0: installs.push(aInstall); michael@0: AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft4_" + aVersion + ".xpi", michael@0: function(aInstall) { michael@0: installs.push(aInstall); michael@0: AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft5_" + aVersion + ".xpi", michael@0: function(aInstall) { michael@0: installs.push(aInstall); michael@0: AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_hard1_" + aVersion + ".xpi", michael@0: function(aInstall) { michael@0: installs.push(aInstall); michael@0: AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_regexp1_" + aVersion + ".xpi", michael@0: function(aInstall) { michael@0: installs.push(aInstall); michael@0: michael@0: Services.obs.addObserver(function(aSubject, aTopic, aData) { michael@0: Services.obs.removeObserver(arguments.callee, "addon-install-blocked"); michael@0: michael@0: aSubject.QueryInterface(Ci.amIWebInstallInfo); michael@0: michael@0: var installCount = aSubject.installs.length; michael@0: michael@0: var listener = { michael@0: installComplete: function() { michael@0: installCount--; michael@0: if (installCount) michael@0: return; michael@0: michael@0: do_execute_soon(aCallback); michael@0: }, michael@0: michael@0: onDownloadCancelled: function(aInstall) { michael@0: this.installComplete(); michael@0: }, michael@0: michael@0: onInstallEnded: function(aInstall) { michael@0: this.installComplete(); michael@0: } michael@0: }; michael@0: michael@0: aSubject.installs.forEach(function(aInstall) { michael@0: aInstall.addListener(listener); michael@0: }); michael@0: michael@0: aSubject.install(); michael@0: }, "addon-install-blocked", false); michael@0: michael@0: AddonManager.installAddonsFromWebpage("application/x-xpinstall", null, michael@0: NetUtil.newURI("http://localhost:" + gPort + "/"), michael@0: installs); michael@0: }, "application/x-xpinstall"); michael@0: }, "application/x-xpinstall"); michael@0: }, "application/x-xpinstall"); michael@0: }, "application/x-xpinstall"); michael@0: }, "application/x-xpinstall"); michael@0: }, "application/x-xpinstall"); michael@0: }, "application/x-xpinstall"); michael@0: } michael@0: michael@0: // Checks that an add-ons properties match expected values michael@0: function check_addon(aAddon, aExpectedVersion, aExpectedUserDisabled, michael@0: aExpectedSoftDisabled, aExpectedState) { michael@0: do_check_neq(aAddon, null); michael@0: dump("Testing " + aAddon.id + " version " + aAddon.version + "\n"); michael@0: dump(aAddon.userDisabled + " " + aAddon.softDisabled + "\n"); michael@0: michael@0: do_check_eq(aAddon.version, aExpectedVersion); michael@0: do_check_eq(aAddon.blocklistState, aExpectedState); michael@0: do_check_eq(aAddon.userDisabled, aExpectedUserDisabled); michael@0: do_check_eq(aAddon.softDisabled, aExpectedSoftDisabled); michael@0: if (aAddon.softDisabled) michael@0: do_check_true(aAddon.userDisabled); michael@0: michael@0: if (aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED) { michael@0: do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE)); michael@0: do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE)); michael@0: } michael@0: else if (aAddon.userDisabled) { michael@0: do_check_true(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE)); michael@0: do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE)); michael@0: } michael@0: else { michael@0: do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE)); michael@0: if (aAddon.type != "theme") michael@0: do_check_true(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE)); michael@0: } michael@0: do_check_eq(aAddon.appDisabled, aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: let willBeActive = aAddon.isActive; michael@0: if (hasFlag(aAddon.pendingOperations, AddonManager.PENDING_DISABLE)) michael@0: willBeActive = false; michael@0: else if (hasFlag(aAddon.pendingOperations, AddonManager.PENDING_ENABLE)) michael@0: willBeActive = true; michael@0: michael@0: if (aExpectedUserDisabled || aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED) { michael@0: do_check_false(willBeActive); michael@0: } michael@0: else { michael@0: do_check_true(willBeActive); michael@0: } michael@0: } michael@0: michael@0: function run_test() { michael@0: do_test_pending("test_blocklistchange main"); michael@0: michael@0: createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); michael@0: writeInstallRDFForExtension(default_theme, profileDir); michael@0: writeInstallRDFForExtension(softblock1_1, profileDir); michael@0: writeInstallRDFForExtension(softblock2_1, profileDir); michael@0: writeInstallRDFForExtension(softblock3_1, profileDir); michael@0: writeInstallRDFForExtension(softblock4_1, profileDir); michael@0: writeInstallRDFForExtension(softblock5_1, profileDir); michael@0: writeInstallRDFForExtension(hardblock_1, profileDir); michael@0: writeInstallRDFForExtension(regexpblock_1, profileDir); michael@0: startupManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, do_exception_wrap(function([s1, s2, s3, s4, s5, h, r]) { michael@0: s4.userDisabled = true; michael@0: s5.userDisabled = false; michael@0: michael@0: run_next_test(); michael@0: })); michael@0: } michael@0: michael@0: // Starts with add-ons unblocked and then switches application versions to michael@0: // change add-ons to blocked and back michael@0: add_test(function run_app_update_test() { michael@0: do_print("Test: " + arguments.callee.name); michael@0: restartManager(); michael@0: load_blocklist("app_update.xml", function app_update_step_1() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "test/1.0"); michael@0: michael@0: do_execute_soon(app_update_step_2); michael@0: }) michael@0: }); michael@0: michael@0: function app_update_step_2() { michael@0: restartManager("2"); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: s2.userDisabled = false; michael@0: s2.userDisabled = true; michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: s3.userDisabled = false; michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: michael@0: do_execute_soon(app_update_step_3); michael@0: }); michael@0: } michael@0: michael@0: function app_update_step_3() { michael@0: restartManager(); michael@0: michael@0: restartManager("2.5"); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: do_execute_soon(app_update_step_4); michael@0: }); michael@0: } michael@0: michael@0: function app_update_step_4() { michael@0: restartManager("1"); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: s1.userDisabled = false; michael@0: s2.userDisabled = false; michael@0: s5.userDisabled = false; michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: }); michael@0: michael@0: // Starts with add-ons unblocked and then switches application versions to michael@0: // change add-ons to blocked and back. A DB schema change is faked to force a michael@0: // rebuild when the application version changes michael@0: add_test(function run_app_update_schema_test() { michael@0: do_print("Test: " + arguments.callee.name); michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "test/1.0"); michael@0: michael@0: do_execute_soon(update_schema_2); michael@0: }); michael@0: michael@0: function update_schema_2() { michael@0: shutdownManager(); michael@0: michael@0: changeXPIDBVersion(100); michael@0: gAppInfo.version = "2"; michael@0: startupManager(true); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: s2.userDisabled = false; michael@0: s2.userDisabled = true; michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: s3.userDisabled = false; michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: do_execute_soon(update_schema_3); michael@0: }); michael@0: } michael@0: michael@0: function update_schema_3() { michael@0: restartManager(); michael@0: michael@0: shutdownManager(); michael@0: changeXPIDBVersion(100); michael@0: gAppInfo.version = "2.5"; michael@0: startupManager(true); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: do_execute_soon(update_schema_4); michael@0: }); michael@0: } michael@0: michael@0: function update_schema_4() { michael@0: shutdownManager(); michael@0: michael@0: changeXPIDBVersion(100); michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: do_execute_soon(update_schema_5); michael@0: }); michael@0: } michael@0: michael@0: function update_schema_5() { michael@0: shutdownManager(); michael@0: michael@0: changeXPIDBVersion(100); michael@0: gAppInfo.version = "1"; michael@0: startupManager(true); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: s1.userDisabled = false; michael@0: s2.userDisabled = false; michael@0: s5.userDisabled = false; michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: }); michael@0: michael@0: // Starts with add-ons unblocked and then loads new blocklists to change add-ons michael@0: // to blocked and back again. michael@0: add_test(function run_blocklist_update_test() { michael@0: do_print("Test: " + arguments.callee.name + "\n"); michael@0: load_blocklist("blocklist_update1.xml", function run_blocklist_update_1() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "test/1.0"); michael@0: michael@0: load_blocklist("blocklist_update2.xml", function run_blocklist_update_2() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: s2.userDisabled = false; michael@0: s2.userDisabled = true; michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: s3.userDisabled = false; michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: michael@0: do_execute_soon(function restart_and_reload() { michael@0: restartManager(); michael@0: michael@0: load_blocklist("blocklist_update2.xml", function run_blocklist_update_3() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: load_blocklist("blocklist_update1.xml", function run_blocklist_update_4() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: s1.userDisabled = false; michael@0: s2.userDisabled = false; michael@0: s5.userDisabled = false; michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Starts with add-ons unblocked and then new versions are installed outside of michael@0: // the app to change them to blocked and back again. michael@0: add_test(function run_addon_change_test() { michael@0: do_print("Test: " + arguments.callee.name + "\n"); michael@0: load_blocklist("addon_change.xml", function run_addon_change_1() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "test/1.0"); michael@0: michael@0: do_execute_soon(run_addon_change_2); michael@0: }); michael@0: }); michael@0: michael@0: function run_addon_change_2() { michael@0: shutdownManager(); michael@0: michael@0: writeInstallRDFForExtension(softblock1_2, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_2.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(softblock2_2, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_2.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(softblock3_2, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_2.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(softblock4_2, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_2.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(softblock5_2, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_2.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(hardblock_2, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_2.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(regexpblock_2, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_2.id), Date.now() + 10000); michael@0: michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: s2.userDisabled = false; michael@0: s2.userDisabled = true; michael@0: check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: s3.userDisabled = false; michael@0: check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: do_execute_soon(run_addon_change_3); michael@0: }); michael@0: } michael@0: michael@0: function run_addon_change_3() { michael@0: restartManager(); michael@0: michael@0: shutdownManager(); michael@0: michael@0: writeInstallRDFForExtension(softblock1_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_3.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(softblock2_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_3.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(softblock3_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_3.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(softblock4_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_3.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(softblock5_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_3.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(hardblock_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_3.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(regexpblock_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_3.id), Date.now() + 20000); michael@0: michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: do_execute_soon(run_addon_change_4); michael@0: }); michael@0: } michael@0: michael@0: function run_addon_change_4() { michael@0: shutdownManager(); michael@0: michael@0: writeInstallRDFForExtension(softblock1_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_1.id), Date.now() + 30000); michael@0: writeInstallRDFForExtension(softblock2_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_1.id), Date.now() + 30000); michael@0: writeInstallRDFForExtension(softblock3_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_1.id), Date.now() + 30000); michael@0: writeInstallRDFForExtension(softblock4_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_1.id), Date.now() + 30000); michael@0: writeInstallRDFForExtension(softblock5_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_1.id), Date.now() + 30000); michael@0: writeInstallRDFForExtension(hardblock_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_1.id), Date.now() + 30000); michael@0: writeInstallRDFForExtension(regexpblock_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_1.id), Date.now() + 30000); michael@0: michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); michael@0: michael@0: s1.userDisabled = false; michael@0: s2.userDisabled = false; michael@0: s5.userDisabled = false; michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: }); michael@0: michael@0: // Starts with add-ons blocked and then new versions are installed outside of michael@0: // the app to change them to unblocked. michael@0: add_test(function run_addon_change_2_test() { michael@0: do_print("Test: " + arguments.callee.name + "\n"); michael@0: shutdownManager(); michael@0: michael@0: getFileForAddon(profileDir, softblock1_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock2_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock3_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock4_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock5_1.id).remove(true); michael@0: getFileForAddon(profileDir, hardblock_1.id).remove(true); michael@0: getFileForAddon(profileDir, regexpblock_1.id).remove(true); michael@0: michael@0: startupManager(false); michael@0: shutdownManager(); michael@0: michael@0: writeInstallRDFForExtension(softblock1_2, profileDir); michael@0: writeInstallRDFForExtension(softblock2_2, profileDir); michael@0: writeInstallRDFForExtension(softblock3_2, profileDir); michael@0: writeInstallRDFForExtension(softblock4_2, profileDir); michael@0: writeInstallRDFForExtension(softblock5_2, profileDir); michael@0: writeInstallRDFForExtension(hardblock_2, profileDir); michael@0: writeInstallRDFForExtension(regexpblock_2, profileDir); michael@0: michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: s2.userDisabled = false; michael@0: s2.userDisabled = true; michael@0: check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: s3.userDisabled = false; michael@0: check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: do_execute_soon(addon_change_2_test_2); michael@0: }); michael@0: michael@0: function addon_change_2_test_2() { michael@0: restartManager(); michael@0: michael@0: shutdownManager(); michael@0: michael@0: writeInstallRDFForExtension(softblock1_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_3.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(softblock2_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_3.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(softblock3_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_3.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(softblock4_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_3.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(softblock5_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_3.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(hardblock_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_3.id), Date.now() + 10000); michael@0: writeInstallRDFForExtension(regexpblock_3, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_3.id), Date.now() + 10000); michael@0: michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: do_execute_soon(addon_change_2_test_3); michael@0: }); michael@0: } michael@0: michael@0: function addon_change_2_test_3() { michael@0: shutdownManager(); michael@0: michael@0: writeInstallRDFForExtension(softblock1_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_1.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(softblock2_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_1.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(softblock3_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_1.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(softblock4_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_1.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(softblock5_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_1.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(hardblock_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_1.id), Date.now() + 20000); michael@0: writeInstallRDFForExtension(regexpblock_1, profileDir); michael@0: setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_1.id), Date.now() + 20000); michael@0: michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: michael@0: s1.userDisabled = false; michael@0: s2.userDisabled = false; michael@0: s4.userDisabled = true; michael@0: s5.userDisabled = false; michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: }); michael@0: michael@0: // Add-ons are initially unblocked then attempts to upgrade to blocked versions michael@0: // in the background which should fail michael@0: add_test(function run_background_update_test() { michael@0: do_print("Test: " + arguments.callee.name + "\n"); michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: michael@0: background_update(function background_update_1() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Starts with add-ons blocked and then new versions are detected and installed michael@0: // automatically for unblocked versions. michael@0: add_test(function run_background_update_2_test() { michael@0: do_print("Test: " + arguments.callee.name + "\n"); michael@0: shutdownManager(); michael@0: michael@0: getFileForAddon(profileDir, softblock1_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock2_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock3_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock4_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock5_1.id).remove(true); michael@0: getFileForAddon(profileDir, hardblock_1.id).remove(true); michael@0: getFileForAddon(profileDir, regexpblock_1.id).remove(true); michael@0: michael@0: startupManager(false); michael@0: shutdownManager(); michael@0: michael@0: writeInstallRDFForExtension(softblock1_3, profileDir); michael@0: writeInstallRDFForExtension(softblock2_3, profileDir); michael@0: writeInstallRDFForExtension(softblock3_3, profileDir); michael@0: writeInstallRDFForExtension(softblock4_3, profileDir); michael@0: writeInstallRDFForExtension(softblock5_3, profileDir); michael@0: writeInstallRDFForExtension(hardblock_3, profileDir); michael@0: writeInstallRDFForExtension(regexpblock_3, profileDir); michael@0: michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: s2.userDisabled = false; michael@0: s2.userDisabled = true; michael@0: check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: s3.userDisabled = false; michael@0: check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: michael@0: // make sure we're not in a handler when we restart michael@0: do_execute_soon(function restart_and_update() { michael@0: restartManager(); michael@0: michael@0: background_update(function background_update_2_1() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: michael@0: s1.userDisabled = false; michael@0: s2.userDisabled = false; michael@0: s4.userDisabled = true; michael@0: s5.userDisabled = true; michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Starts with add-ons blocked and then simulates the user upgrading them to michael@0: // unblocked versions. michael@0: add_test(function run_manual_update_test() { michael@0: do_print("Test: " + arguments.callee.name + "\n"); michael@0: restartManager(); michael@0: load_blocklist("manual_update.xml", function manual_update_1() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: s2.userDisabled = false; michael@0: s2.userDisabled = true; michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: s3.userDisabled = false; michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: michael@0: do_execute_soon(function restart_manual_update() { michael@0: restartManager(); michael@0: michael@0: manual_update("2", function manual_update_2() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s4, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s5, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: // Can't manually update to a hardblocked add-on michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: manual_update("3", function manual_update_3() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s4, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s5, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Starts with add-ons blocked and then new versions are installed outside of michael@0: // the app to change them to unblocked. michael@0: add_test(function run_manual_update_2_test() { michael@0: do_print("Test: " + arguments.callee.name + "\n"); michael@0: shutdownManager(); michael@0: michael@0: getFileForAddon(profileDir, softblock1_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock2_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock3_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock4_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock5_1.id).remove(true); michael@0: getFileForAddon(profileDir, hardblock_1.id).remove(true); michael@0: getFileForAddon(profileDir, regexpblock_1.id).remove(true); michael@0: michael@0: startupManager(false); michael@0: shutdownManager(); michael@0: michael@0: writeInstallRDFForExtension(softblock1_1, profileDir); michael@0: writeInstallRDFForExtension(softblock2_1, profileDir); michael@0: writeInstallRDFForExtension(softblock3_1, profileDir); michael@0: writeInstallRDFForExtension(softblock4_1, profileDir); michael@0: writeInstallRDFForExtension(softblock5_1, profileDir); michael@0: writeInstallRDFForExtension(hardblock_1, profileDir); michael@0: writeInstallRDFForExtension(regexpblock_1, profileDir); michael@0: michael@0: startupManager(false); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, callback_soon(function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: s2.userDisabled = false; michael@0: s2.userDisabled = true; michael@0: check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: s3.userDisabled = false; michael@0: check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: restartManager(); michael@0: michael@0: manual_update("2", function manual_update_2_2() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, michael@0: callback_soon(function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: // Can't manually update to a hardblocked add-on michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: restartManager(); michael@0: michael@0: manual_update("3", function manual_update_2_3() { michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); michael@0: michael@0: s1.userDisabled = false; michael@0: s2.userDisabled = false; michael@0: s4.userDisabled = true; michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: })); michael@0: }); michael@0: })); michael@0: }); michael@0: michael@0: // Uses the API to install blocked add-ons from the local filesystem michael@0: add_test(function run_local_install_test() { michael@0: do_print("Test: " + arguments.callee.name + "\n"); michael@0: shutdownManager(); michael@0: michael@0: getFileForAddon(profileDir, softblock1_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock2_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock3_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock4_1.id).remove(true); michael@0: getFileForAddon(profileDir, softblock5_1.id).remove(true); michael@0: getFileForAddon(profileDir, hardblock_1.id).remove(true); michael@0: getFileForAddon(profileDir, regexpblock_1.id).remove(true); michael@0: michael@0: startupManager(false); michael@0: michael@0: installAllFiles([ michael@0: do_get_file("addons/blocklist_soft1_1.xpi"), michael@0: do_get_file("addons/blocklist_soft2_1.xpi"), michael@0: do_get_file("addons/blocklist_soft3_1.xpi"), michael@0: do_get_file("addons/blocklist_soft4_1.xpi"), michael@0: do_get_file("addons/blocklist_soft5_1.xpi"), michael@0: do_get_file("addons/blocklist_hard1_1.xpi"), michael@0: do_get_file("addons/blocklist_regexp1_1.xpi") michael@0: ], function local_install_1() { michael@0: AddonManager.getAllInstalls(function(aInstalls) { michael@0: // Should have finished all installs without needing to restart michael@0: do_check_eq(aInstalls.length, 0); michael@0: michael@0: AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { michael@0: michael@0: check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); michael@0: check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function shutdown_httpserver() { michael@0: testserver.stop(function() { michael@0: do_test_finished("test_blocklistchange main"); michael@0: // this really means "async test step done"; needs to be called michael@0: // even when there isn't a next test michael@0: run_next_test(); michael@0: }); michael@0: });