diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js index b88da9e9478e..8203a41d7224 100644 --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js @@ -2060,11 +2060,11 @@ this.XPIDatabaseReconcile = { BOOTSTRAP_REASONS.ADDON_UPGRADE : BOOTSTRAP_REASONS.ADDON_DOWNGRADE; - // If the previous add-on was in a different path, bootstrapped + // If the previous add-on was in a different location, bootstrapped // and still exists then call its uninstall method. if (previousAddon.bootstrap && previousAddon._installLocation && - previousAddon._sourceBundle.exists() && - currentAddon._sourceBundle.path != previousAddon._sourceBundle.path) { + currentAddon._installLocation != previousAddon._installLocation && + previousAddon._sourceBundle.exists()) { XPIProvider.callBootstrapMethod(previousAddon, previousAddon._sourceBundle, "uninstall", installReason, @@ -2118,18 +2118,7 @@ this.XPIDatabaseReconcile = { continue; // This add-on vanished - - // If the previous add-on was bootstrapped and still exists then call its - // uninstall method. - if (previousAddon.bootstrap && previousAddon._sourceBundle.exists()) { - XPIProvider.callBootstrapMethod(previousAddon, previousAddon._sourceBundle, - "uninstall", BOOTSTRAP_REASONS.ADDON_UNINSTALL); - XPIProvider.unloadBootstrapScope(previousAddon.id); - } AddonManagerPrivate.addStartupChange(AddonManager.STARTUP_CHANGE_UNINSTALLED, id); - - // Make sure to flush the cache when an old add-on has gone away - flushStartupCache(); } // Make sure add-ons from hidden locations are marked invisible and inactive diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/bootstrap.js index 1666f2972c37..eba6762c8afd 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/bootstrap.js +++ b/toolkit/mozapps/extensions/test/addons/test_bootstrap1_1/bootstrap.js @@ -1 +1,32 @@ -Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this); +Components.utils.import("resource://gre/modules/Services.jsm"); + +// Test steps chain from pref observers on *_reason, +// so always set that last +function install(data, reason) { + Components.utils.import(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.installed_version", VERSION); + Services.prefs.setIntPref("bootstraptest.install_oldversion", data.oldVersion); + Components.utils.unload(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.install_reason", reason); +} + +function startup(data, reason) { + Components.utils.reportError("bootstrap startup"); + Components.utils.import(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.active_version", VERSION); + Services.prefs.setIntPref("bootstraptest.startup_oldversion", data.oldVersion); + Components.utils.unload(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.startup_reason", reason); +} + +function shutdown(data, reason) { + Services.prefs.setIntPref("bootstraptest.active_version", 0); + Services.prefs.setIntPref("bootstraptest.shutdown_newversion", data.newVersion); + Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason); +} + +function uninstall(data, reason) { + Services.prefs.setIntPref("bootstraptest.installed_version", 0); + Services.prefs.setIntPref("bootstraptest.uninstall_newversion", data.newVersion); + Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason); +} diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/bootstrap.js index 1666f2972c37..8839bfb7dc17 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/bootstrap.js +++ b/toolkit/mozapps/extensions/test/addons/test_bootstrap1_2/bootstrap.js @@ -1 +1,31 @@ -Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this); +Components.utils.import("resource://gre/modules/Services.jsm"); + +// Test steps chain from pref observers on *_reason, +// so always set that last +function install(data, reason) { + Components.utils.import(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.installed_version", VERSION); + Services.prefs.setIntPref("bootstraptest.install_oldversion", data.oldVersion); + Components.utils.unload(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.install_reason", reason); +} + +function startup(data, reason) { + Components.utils.import(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.active_version", VERSION); + Services.prefs.setIntPref("bootstraptest.startup_oldversion", data.oldVersion); + Components.utils.unload(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.startup_reason", reason); +} + +function shutdown(data, reason) { + Services.prefs.setIntPref("bootstraptest.active_version", 0); + Services.prefs.setIntPref("bootstraptest.shutdown_newversion", data.newVersion); + Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason); +} + +function uninstall(data, reason) { + Services.prefs.setIntPref("bootstraptest.installed_version", 0); + Services.prefs.setIntPref("bootstraptest.uninstall_newversion", data.newVersion); + Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason); +} diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/bootstrap.js index 1666f2972c37..8839bfb7dc17 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/bootstrap.js +++ b/toolkit/mozapps/extensions/test/addons/test_bootstrap1_3/bootstrap.js @@ -1 +1,31 @@ -Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this); +Components.utils.import("resource://gre/modules/Services.jsm"); + +// Test steps chain from pref observers on *_reason, +// so always set that last +function install(data, reason) { + Components.utils.import(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.installed_version", VERSION); + Services.prefs.setIntPref("bootstraptest.install_oldversion", data.oldVersion); + Components.utils.unload(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.install_reason", reason); +} + +function startup(data, reason) { + Components.utils.import(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.active_version", VERSION); + Services.prefs.setIntPref("bootstraptest.startup_oldversion", data.oldVersion); + Components.utils.unload(data.resourceURI.spec + "version.jsm"); + Services.prefs.setIntPref("bootstraptest.startup_reason", reason); +} + +function shutdown(data, reason) { + Services.prefs.setIntPref("bootstraptest.active_version", 0); + Services.prefs.setIntPref("bootstraptest.shutdown_newversion", data.newVersion); + Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason); +} + +function uninstall(data, reason) { + Services.prefs.setIntPref("bootstraptest.installed_version", 0); + Services.prefs.setIntPref("bootstraptest.uninstall_newversion", data.newVersion); + Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason); +} diff --git a/toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/bootstrap.js index 1666f2972c37..476edfeeee83 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/bootstrap.js +++ b/toolkit/mozapps/extensions/test/addons/test_bootstrap2_1/bootstrap.js @@ -1 +1,17 @@ -Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this); +Components.utils.import("resource://gre/modules/Services.jsm"); + +function install(data, reason) { + Services.prefs.setIntPref("bootstraptest2.installed_version", 1); +} + +function startup(data, reason) { + Services.prefs.setIntPref("bootstraptest2.active_version", 1); +} + +function shutdown(data, reason) { + Services.prefs.setIntPref("bootstraptest2.active_version", 0); +} + +function uninstall(data, reason) { + Services.prefs.setIntPref("bootstraptest2.installed_version", 0); +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm b/toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm deleted file mode 100644 index dfc0eaf3207a..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm +++ /dev/null @@ -1,28 +0,0 @@ -Components.utils.import("resource://gre/modules/Services.jsm"); - -this.EXPORTED_SYMBOLS = [ "monitor" ]; - -function notify(event, originalMethod, data, reason) { - let info = { - event, - data: Object.assign({}, data, { - installPath: data.installPath.path, - resourceURI: data.resourceURI.spec, - }), - reason - }; - - Services.obs.notifyObservers(null, "bootstrapmonitor-event", JSON.stringify(info)); - - // If the bootstrap scope already declares a method call it - if (originalMethod) - originalMethod(data, reason); -} - -// Allows a simple one-line bootstrap script: -// Components.utils.import("resource://xpcshelldata/bootstrapmonitor.jsm").monitor(this); -this.monitor = function(scope) { - for (let event of ["install", "startup", "shutdown", "uninstall"]) { - scope[event] = notify.bind(null, event, scope[event]); - } -} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js deleted file mode 100644 index 1666f2972c37..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js +++ /dev/null @@ -1 +0,0 @@ -Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this); diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi index 31724aec5ad7..d04bca194bd0 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi index e7e50c8ea878..d6a8e727a1b8 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi index b32544487303..b95192c26fab 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi index af5e5cb21f7a..a4d7f4d18e71 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi index aefc9a96aa60..7af871d36dec 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi index 49369ad2f51c..5c8570dcc408 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi index d43bde916d9f..60bcde626ffd 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi index 873e34c95de6..5b50b8556dcf 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi index 3a3c4f3e08ec..91a7d9ffc1e8 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi index 060b4e8400f1..a11a8eb494f1 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi index ec2d39b623bf..f4e07bf300d1 100644 Binary files a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi and b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi differ diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js index 33faffad45e2..2f0c263d65e4 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js +++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js @@ -61,123 +61,6 @@ var gUrlToFileMap = {}; var TEST_UNPACKED = false; -// Map resource://xpcshell-data/ to the data directory -let resHandler = Services.io.getProtocolHandler("resource") - .QueryInterface(AM_Ci.nsISubstitutingProtocolHandler); -// Allow non-existent files because of bug 1207735 -let dataURI = NetUtil.newURI(do_get_file("data", true)); -resHandler.setSubstitution("xpcshell-data", dataURI); - -// Listens to messages from bootstrap.js telling us what add-ons were started -// and stopped etc. and performs some sanity checks that only installed add-ons -// are started etc. -this.BootstrapMonitor = { - // Contain the current state of add-ons in the system - installed: new Map(), - started: new Map(), - - // Contain the last state of shutdown and uninstall calls for an add-on - stopped: new Map(), - uninstalled: new Map(), - - startupPromises: [], - installPromises: [], - - init() { - Services.obs.addObserver(this, "bootstrapmonitor-event", false); - }, - - clear(id) { - this.installed.delete(id); - this.started.delete(id); - this.stopped.delete(id); - this.uninstalled.delete(id); - }, - - promiseAddonStartup(id) { - return new Promise(resolve => { - this.startupPromises.push(resolve); - }); - }, - - promiseAddonInstall(id) { - return new Promise(resolve => { - this.installPromises.push(resolve); - }); - }, - - checkMatches(cached, current) { - do_check_neq(cached, undefined); - do_check_eq(current.data.version, cached.data.version) - do_check_eq(current.data.installPath, cached.data.installPath) - do_check_eq(current.data.resourceURI, cached.data.resourceURI) - }, - - checkAddonStarted(id, version = undefined) { - let started = this.started.get(id); - do_check_neq(started, undefined); - if (version != undefined) - do_check_eq(started.data.version, version); - }, - - checkAddonNotStarted(id) { - do_check_false(this.started.has(id)); - }, - - checkAddonInstalled(id, version = undefined) { - let installed = this.installed.get(id); - do_check_neq(installed, undefined); - if (version != undefined) - do_check_eq(installed.data.version, version); - }, - - checkAddonNotInstalled(id) { - do_check_false(this.installed.has(id)); - }, - - observe(subject, topic, data) { - let info = JSON.parse(data); - let id = info.data.id; - - // If this is the install event the add-ons shouldn't already be installed - if (info.event == "install") { - this.checkAddonNotInstalled(id); - - this.installed.set(id, info); - - for (let resolve of this.installPromises) - resolve(); - this.installPromises = []; - } - else { - this.checkMatches(this.installed.get(id), info); - } - - // If this is the shutdown event than the add-on should already be started - if (info.event == "shutdown") { - this.checkMatches(this.started.get(id), info); - - this.started.delete(id); - this.stopped.set(id, info); - } - else { - this.checkAddonNotStarted(id); - } - - if (info.event == "uninstall") { - this.installed.delete(id); - this.uninstalled.set(id, info) - } - else if (info.event == "startup") { - this.started.set(id, info); - - for (let resolve of this.startupPromises) - resolve(); - this.startupPromises = []; - } - } -} - function isNightlyChannel() { var channel = "default"; try { diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js index 291c7a1083e0..5825cde45571 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js @@ -11,9 +11,6 @@ const ADDON_UNINSTALL = 6; const ADDON_UPGRADE = 7; const ADDON_DOWNGRADE = 8; -const ID1 = "bootstrap1@tests.mozilla.org"; -const ID2 = "bootstrap2@tests.mozilla.org"; - // This verifies that bootstrappable add-ons can be used without restarts. Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Promise.jsm"); @@ -22,8 +19,6 @@ Components.utils.import("resource://gre/modules/Promise.jsm"); Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_USER); -BootstrapMonitor.init(); - createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); const profileDir = gProfD.clone(); @@ -35,49 +30,99 @@ registerDirectory("XREUSysExt", userExtDir.parent); Components.utils.import("resource://testing-common/httpd.js"); var testserver = new HttpServer(); -testserver.start(undefined); +testserver.start(-1); gPort = testserver.identity.primaryPort; testserver.registerDirectory("/addons/", do_get_file("addons")); +function resetPrefs() { + Services.prefs.setIntPref("bootstraptest.active_version", -1); + Services.prefs.setIntPref("bootstraptest.installed_version", -1); + Services.prefs.setIntPref("bootstraptest2.active_version", -1); + Services.prefs.setIntPref("bootstraptest2.installed_version", -1); + Services.prefs.setIntPref("bootstraptest.startup_reason", -1); + Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1); + Services.prefs.setIntPref("bootstraptest.install_reason", -1); + Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1); + Services.prefs.setIntPref("bootstraptest.startup_oldversion", -1); + Services.prefs.setIntPref("bootstraptest.shutdown_newversion", -1); + Services.prefs.setIntPref("bootstraptest.install_oldversion", -1); + Services.prefs.setIntPref("bootstraptest.uninstall_newversion", -1); +} + +function waitForPref(aPref, aCallback) { + function prefChanged() { + Services.prefs.removeObserver(aPref, prefChanged); + // Always let whoever set the preference keep running + do_execute_soon(aCallback); + } + Services.prefs.addObserver(aPref, prefChanged, false); +} + +function promisePref(aPref) { + let deferred = Promise.defer(); + + waitForPref(aPref, deferred.resolve.bind(deferred)); + + return deferred.promise; +} + +function promiseInstall(aFiles) { + let deferred = Promise.defer(); + + installAllFiles(aFiles, function() { + deferred.resolve(); + }); + + return deferred.promise; +} + +function getActiveVersion() { + return Services.prefs.getIntPref("bootstraptest.active_version"); +} + +function getInstalledVersion() { + return Services.prefs.getIntPref("bootstraptest.installed_version"); +} + +function getActiveVersion2() { + return Services.prefs.getIntPref("bootstraptest2.active_version"); +} + +function getInstalledVersion2() { + return Services.prefs.getIntPref("bootstraptest2.installed_version"); +} + function getStartupReason() { - let info = BootstrapMonitor.started.get(ID1); - return info ? info.reason : undefined; + return Services.prefs.getIntPref("bootstraptest.startup_reason"); } function getShutdownReason() { - let info = BootstrapMonitor.stopped.get(ID1); - return info ? info.reason : undefined; + return Services.prefs.getIntPref("bootstraptest.shutdown_reason"); } function getInstallReason() { - let info = BootstrapMonitor.installed.get(ID1); - return info ? info.reason : undefined; + return Services.prefs.getIntPref("bootstraptest.install_reason"); } function getUninstallReason() { - let info = BootstrapMonitor.uninstalled.get(ID1); - return info ? info.reason : undefined; + return Services.prefs.getIntPref("bootstraptest.uninstall_reason"); } function getStartupOldVersion() { - let info = BootstrapMonitor.started.get(ID1); - return info ? info.data.oldVersion : undefined; + return Services.prefs.getIntPref("bootstraptest.startup_oldversion"); } function getShutdownNewVersion() { - let info = BootstrapMonitor.stopped.get(ID1); - return info ? info.data.newVersion : undefined; + return Services.prefs.getIntPref("bootstraptest.shutdown_newversion"); } function getInstallOldVersion() { - let info = BootstrapMonitor.installed.get(ID1); - return info ? info.data.oldVersion : undefined; + return Services.prefs.getIntPref("bootstraptest.install_oldversion"); } function getUninstallNewVersion() { - let info = BootstrapMonitor.uninstalled.get(ID1); - return info ? info.data.newVersion : undefined; + return Services.prefs.getIntPref("bootstraptest.uninstall_newversion"); } function do_check_bootstrappedPref(aCallback) { @@ -112,6 +157,8 @@ function do_check_bootstrappedPref(aCallback) { function run_test() { do_test_pending(); + resetPrefs(); + startupManager(); do_check_false(gExtensionsJSON.exists()); @@ -141,18 +188,18 @@ function run_test_1() { do_check_false(install.addon.hasResource("foo.bar")); do_check_eq(install.addon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_INSTALL, 0); - do_check_not_in_crash_annotation(ID1, "1.0"); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); let addon = install.addon; - BootstrapMonitor.promiseAddonStartup(ID1).then(function() { + waitForPref("bootstraptest.startup_reason", function() { do_check_bootstrappedPref(function() { check_test_1(addon.syncGUID); }); }); prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onInstalling", false], "onInstalled" ] @@ -163,7 +210,7 @@ function run_test_1() { do_check_true(addon.hasResource("install.rdf")); // startup should not have been called yet. - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getActiveVersion(), -1); }); install.install(); }); @@ -177,7 +224,7 @@ function check_test_1(installSyncGUID) { // doesn't require a restart. do_check_eq(installs.length, 0); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_neq(b1.syncGUID, null); @@ -185,16 +232,16 @@ function check_test_1(installSyncGUID) { do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_eq(getStartupReason(), ADDON_INSTALL); - do_check_eq(getStartupOldVersion(), undefined); + do_check_eq(getStartupOldVersion(), 0); do_check_true(b1.hasResource("install.rdf")); do_check_true(b1.hasResource("bootstrap.js")); do_check_false(b1.hasResource("foo.bar")); - do_check_in_crash_annotation(ID1, "1.0"); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); - let dir = do_get_addon_root_uri(profileDir, ID1); + let dir = do_get_addon_root_uri(profileDir, "bootstrap1@tests.mozilla.org"); do_check_eq(b1.getResourceURI("bootstrap.js").spec, dir + "bootstrap.js"); AddonManager.getAddonsWithOperationsByTypes(null, function(list) { @@ -208,9 +255,9 @@ function check_test_1(installSyncGUID) { // Tests that disabling doesn't require a restart function run_test_2() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onDisabling", false], "onDisabled" ] @@ -226,13 +273,13 @@ function run_test_2() { do_check_false(b1.appDisabled); do_check_true(b1.userDisabled); do_check_false(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); do_check_eq(getShutdownReason(), ADDON_DISABLE); - do_check_eq(getShutdownNewVersion(), undefined); - do_check_not_in_crash_annotation(ID1, "1.0"); + do_check_eq(getShutdownNewVersion(), 0); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); - AddonManager.getAddonByID(ID1, function(newb1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(newb1) { do_check_neq(newb1, null); do_check_eq(newb1.version, "1.0"); do_check_false(newb1.appDisabled); @@ -247,20 +294,20 @@ function run_test_2() { // Test that restarting doesn't accidentally re-enable function run_test_3() { shutdownManager(); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); do_check_eq(getShutdownReason(), ADDON_DISABLE); - do_check_eq(getShutdownNewVersion(), undefined); + do_check_eq(getShutdownNewVersion(), 0); startupManager(false); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); do_check_eq(getShutdownReason(), ADDON_DISABLE); - do_check_eq(getShutdownNewVersion(), undefined); - do_check_not_in_crash_annotation(ID1, "1.0"); + do_check_eq(getShutdownNewVersion(), 0); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); do_check_false(gExtensionsINI.exists()); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_false(b1.appDisabled); @@ -273,9 +320,9 @@ function run_test_3() { // Tests that enabling doesn't require a restart function run_test_4() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onEnabling", false], "onEnabled" ] @@ -291,13 +338,13 @@ function run_test_4() { do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_eq(getStartupReason(), ADDON_ENABLE); - do_check_eq(getStartupOldVersion(), undefined); - do_check_in_crash_annotation(ID1, "1.0"); + do_check_eq(getStartupOldVersion(), 0); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); - AddonManager.getAddonByID(ID1, function(newb1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(newb1) { do_check_neq(newb1, null); do_check_eq(newb1.version, "1.0"); do_check_false(newb1.appDisabled); @@ -315,19 +362,19 @@ function run_test_5() { // By the time we've shut down, the database must have been written do_check_true(gExtensionsJSON.exists()); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); do_check_eq(getShutdownReason(), APP_SHUTDOWN); - do_check_eq(getShutdownNewVersion(), undefined); - do_check_not_in_crash_annotation(ID1, "1.0"); + do_check_eq(getShutdownNewVersion(), 0); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); startupManager(false); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_eq(getStartupReason(), APP_STARTUP); - do_check_eq(getStartupOldVersion(), undefined); - do_check_in_crash_annotation(ID1, "1.0"); + do_check_eq(getStartupOldVersion(), 0); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_false(b1.appDisabled); @@ -354,9 +401,9 @@ function run_test_6() { do_check_eq(install.name, "Test Bootstrap 1"); do_check_eq(install.state, AddonManager.STATE_DOWNLOADED); - BootstrapMonitor.promiseAddonStartup(ID1).then(check_test_6); + waitForPref("bootstraptest.startup_reason", check_test_6); prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onInstalling", false], "onInstalled" ] @@ -370,22 +417,22 @@ function run_test_6() { } function check_test_6() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "2.0"); do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "2.0"); - BootstrapMonitor.checkAddonStarted(ID1, "2.0"); + do_check_eq(getInstalledVersion(), 2); + do_check_eq(getActiveVersion(), 2); do_check_eq(getStartupReason(), ADDON_UPGRADE); do_check_eq(getInstallOldVersion(), 1); do_check_eq(getStartupOldVersion(), 1); do_check_eq(getShutdownReason(), ADDON_UPGRADE); do_check_eq(getShutdownNewVersion(), 2); do_check_eq(getUninstallNewVersion(), 2); - do_check_not_in_crash_annotation(ID1, "1.0"); - do_check_in_crash_annotation(ID1, "2.0"); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0"); do_check_bootstrappedPref(run_test_7); }); @@ -393,9 +440,9 @@ function check_test_6() { // Tests that uninstalling doesn't require a restart function run_test_7() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onUninstalling", false], "onUninstalled" ] @@ -411,18 +458,18 @@ function run_test_7() { function check_test_7() { ensure_test_completed(); - BootstrapMonitor.checkAddonNotInstalled(ID1); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 0); + do_check_eq(getActiveVersion(), 0); do_check_eq(getShutdownReason(), ADDON_UNINSTALL); - do_check_eq(getShutdownNewVersion(), undefined); - do_check_not_in_crash_annotation(ID1, "2.0"); + do_check_eq(getShutdownNewVersion(), 0); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0"); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { do_check_eq(b1, null); restartManager(); - AddonManager.getAddonByID(ID1, function(newb1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(newb1) { do_check_eq(newb1, null); do_check_bootstrappedPref(run_test_8); @@ -436,21 +483,21 @@ function run_test_8() { shutdownManager(); manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, - ID1); + "bootstrap1@tests.mozilla.org"); startupManager(false); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_eq(getStartupReason(), ADDON_INSTALL); - do_check_eq(getStartupOldVersion(), undefined); - do_check_in_crash_annotation(ID1, "1.0"); + do_check_eq(getStartupOldVersion(), 0); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); do_check_bootstrappedPref(run_test_9); }); @@ -460,14 +507,13 @@ function run_test_8() { function run_test_9() { shutdownManager(); - manuallyUninstall(profileDir, ID1); - BootstrapMonitor.clear(ID1); + manuallyUninstall(profileDir, "bootstrap1@tests.mozilla.org"); startupManager(false); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_eq(b1, null); - do_check_not_in_crash_annotation(ID1, "1.0"); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); do_check_bootstrappedPref(run_test_10); }); @@ -476,6 +522,7 @@ function run_test_9() { // Tests that installing a downgrade sends the right reason function run_test_10() { + resetPrefs(); prepare_test({ }, [ "onNewInstall" ]); @@ -491,11 +538,11 @@ function run_test_10() { do_check_true(install.addon.hasResource("install.rdf")); do_check_true(install.addon.hasResource("bootstrap.js")); do_check_false(install.addon.hasResource("foo.bar")); - do_check_not_in_crash_annotation(ID1, "2.0"); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0"); - BootstrapMonitor.promiseAddonStartup(ID1).then(check_test_10_pt1); + waitForPref("bootstraptest.startup_reason", check_test_10_pt1); prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onInstalling", false], "onInstalled" ] @@ -510,20 +557,20 @@ function run_test_10() { } function check_test_10_pt1() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "2.0"); do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "2.0"); - BootstrapMonitor.checkAddonStarted(ID1, "2.0"); + do_check_eq(getInstalledVersion(), 2); + do_check_eq(getActiveVersion(), 2); do_check_eq(getStartupReason(), ADDON_INSTALL); - do_check_eq(getStartupOldVersion(), undefined); + do_check_eq(getStartupOldVersion(), 0); do_check_true(b1.hasResource("install.rdf")); do_check_true(b1.hasResource("bootstrap.js")); do_check_false(b1.hasResource("foo.bar")); - do_check_in_crash_annotation(ID1, "2.0"); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0"); prepare_test({ }, [ "onNewInstall" @@ -538,9 +585,9 @@ function check_test_10_pt1() { do_check_eq(install.name, "Test Bootstrap 1"); do_check_eq(install.state, AddonManager.STATE_DOWNLOADED); - BootstrapMonitor.promiseAddonStartup(ID1).then(check_test_10_pt2); + waitForPref("bootstraptest.startup_reason", check_test_10_pt2); prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onInstalling", false], "onInstalled" ] @@ -554,22 +601,22 @@ function check_test_10_pt1() { } function check_test_10_pt2() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_eq(getStartupReason(), ADDON_DOWNGRADE); do_check_eq(getInstallOldVersion(), 2); do_check_eq(getStartupOldVersion(), 2); do_check_eq(getShutdownReason(), ADDON_DOWNGRADE); do_check_eq(getShutdownNewVersion(), 1); do_check_eq(getUninstallNewVersion(), 1); - do_check_in_crash_annotation(ID1, "1.0"); - do_check_not_in_crash_annotation(ID1, "2.0"); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0"); do_check_bootstrappedPref(run_test_11); }); @@ -577,9 +624,9 @@ function check_test_10_pt2() { // Tests that uninstalling a disabled add-on still calls the uninstall method function run_test_11() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onDisabling", false], "onDisabled", ["onUninstalling", false], @@ -589,11 +636,11 @@ function run_test_11() { b1.userDisabled = true; - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); do_check_eq(getShutdownReason(), ADDON_DISABLE); - do_check_eq(getShutdownNewVersion(), undefined); - do_check_not_in_crash_annotation(ID1, "1.0"); + do_check_eq(getShutdownNewVersion(), 0); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); b1.uninstall(); @@ -603,9 +650,9 @@ function run_test_11() { function check_test_11() { ensure_test_completed(); - BootstrapMonitor.checkAddonNotInstalled(ID1); - BootstrapMonitor.checkAddonNotStarted(ID1); - do_check_not_in_crash_annotation(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 0); + do_check_eq(getActiveVersion(), 0); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); do_check_bootstrappedPref(run_test_12); } @@ -616,21 +663,21 @@ function run_test_12() { shutdownManager(); manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, - ID1); + "bootstrap1@tests.mozilla.org"); startupManager(true); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_eq(getStartupReason(), ADDON_INSTALL); - do_check_eq(getStartupOldVersion(), undefined); - do_check_in_crash_annotation(ID1, "1.0"); + do_check_eq(getStartupOldVersion(), 0); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); b1.uninstall(); do_execute_soon(test_12_restart); @@ -658,10 +705,10 @@ function run_test_13() { do_check_eq(install.version, "3.0"); do_check_eq(install.name, "Test Bootstrap 1"); do_check_eq(install.state, AddonManager.STATE_DOWNLOADED); - do_check_not_in_crash_annotation(ID1, "3.0"); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "3.0"); prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onInstalling", false], "onInstalled" ] @@ -679,15 +726,15 @@ function check_test_13() { // doesn't require a restart. do_check_eq(installs.length, 0); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "3.0"); do_check_true(b1.appDisabled); do_check_false(b1.userDisabled); do_check_false(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "3.0"); // We call install even for disabled add-ons - BootstrapMonitor.checkAddonNotStarted(ID1); // Should not have called startup though - do_check_not_in_crash_annotation(ID1, "3.0"); + do_check_eq(getInstalledVersion(), 3); // We call install even for disabled add-ons + do_check_eq(getActiveVersion(), 0); // Should not have called startup though + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "3.0"); do_execute_soon(test_13_restart); }); @@ -697,15 +744,15 @@ function check_test_13() { function test_13_restart() { restartManager(); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "3.0"); do_check_true(b1.appDisabled); do_check_false(b1.userDisabled); do_check_false(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "3.0"); // We call install even for disabled add-ons - BootstrapMonitor.checkAddonNotStarted(ID1); // Should not have called startup though - do_check_not_in_crash_annotation(ID1, "3.0"); + do_check_eq(getInstalledVersion(), 3); // We call install even for disabled add-ons + do_check_eq(getActiveVersion(), 0); // Should not have called startup though + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "3.0"); do_check_bootstrappedPref(function() { b1.uninstall(); @@ -722,19 +769,19 @@ function run_test_14() { shutdownManager(); manuallyInstall(do_get_addon("test_bootstrap1_3"), profileDir, - ID1); + "bootstrap1@tests.mozilla.org"); startupManager(false); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "3.0"); do_check_true(b1.appDisabled); do_check_false(b1.userDisabled); do_check_false(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "3.0"); // We call install even for disabled add-ons - BootstrapMonitor.checkAddonNotStarted(ID1); // Should not have called startup though - do_check_not_in_crash_annotation(ID1, "3.0"); + do_check_eq(getInstalledVersion(), 3); // We call install even for disabled add-ons + do_check_eq(getActiveVersion(), 0); // Should not have called startup though + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "3.0"); do_check_bootstrappedPref(function() { b1.uninstall(); @@ -747,20 +794,21 @@ function run_test_14() { // Tests that upgrading a disabled bootstrapped extension still calls uninstall // and install but doesn't startup the new version function run_test_15() { - BootstrapMonitor.promiseAddonStartup(ID1).then(function test_15_after_startup() { - AddonManager.getAddonByID(ID1, function(b1) { + resetPrefs(); + waitForPref("bootstraptest.startup_reason", function test_15_after_startup() { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); b1.userDisabled = true; do_check_false(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); prepare_test({ }, [ "onNewInstall" @@ -773,7 +821,7 @@ function run_test_15() { do_check_true(install.addon.userDisabled); prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onInstalling", false], "onInstalled" ] @@ -789,26 +837,26 @@ function run_test_15() { } function check_test_15() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "2.0"); do_check_false(b1.appDisabled); do_check_true(b1.userDisabled); do_check_false(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "2.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 2); + do_check_eq(getActiveVersion(), 0); do_check_bootstrappedPref(function() { restartManager(); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "2.0"); do_check_false(b1.appDisabled); do_check_true(b1.userDisabled); do_check_false(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "2.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 2); + do_check_eq(getActiveVersion(), 0); b1.uninstall(); @@ -820,11 +868,12 @@ function check_test_15() { // Tests that bootstrapped extensions don't get loaded when in safe mode function run_test_16() { - BootstrapMonitor.promiseAddonStartup(ID1).then(function test_16_after_startup() { - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + resetPrefs(); + waitForPref("bootstraptest.startup_reason", function test_16_after_startup() { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { // Should have installed and started - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_true(b1.isActive); do_check_eq(b1.iconURL, "chrome://foo/skin/icon.png"); do_check_eq(b1.aboutURL, "chrome://foo/content/about.xul"); @@ -833,16 +882,16 @@ function run_test_16() { shutdownManager(); // Should have stopped - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); gAppInfo.inSafeMode = true; startupManager(false); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { // Should still be stopped - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); do_check_false(b1.isActive); do_check_eq(b1.iconURL, null); do_check_eq(b1.aboutURL, null); @@ -853,10 +902,10 @@ function run_test_16() { startupManager(false); // Should have started - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { b1.uninstall(); do_execute_soon(run_test_17); @@ -872,14 +921,15 @@ function run_test_17() { shutdownManager(); manuallyInstall(do_get_addon("test_bootstrap1_1"), userExtDir, - ID1); + "bootstrap1@tests.mozilla.org"); + resetPrefs(); startupManager(); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { // Should have installed and started - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_true(b1.isActive); @@ -891,11 +941,12 @@ function run_test_17() { // Check that installing a new bootstrapped extension in the profile replaces // the existing one function run_test_18() { - BootstrapMonitor.promiseAddonStartup(ID1).then(function test_18_after_startup() { - AddonManager.getAddonByID(ID1, function(b1) { + resetPrefs(); + waitForPref("bootstraptest.startup_reason", function test_18_after_startup() { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { // Should have installed and started - BootstrapMonitor.checkAddonInstalled(ID1, "2.0"); - BootstrapMonitor.checkAddonStarted(ID1, "2.0"); + do_check_eq(getInstalledVersion(), 2); + do_check_eq(getActiveVersion(), 2); do_check_neq(b1, null); do_check_eq(b1.version, "2.0"); do_check_true(b1.isActive); @@ -918,10 +969,11 @@ function run_test_18() { // Check that uninstalling the profile version reveals the non-profile one function run_test_19() { - AddonManager.getAddonByID(ID1, function(b1) { + resetPrefs(); + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { // The revealed add-on gets activated asynchronously prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onUninstalling", false], "onUninstalled", ["onInstalling", false], @@ -934,10 +986,10 @@ function run_test_19() { } function check_test_19() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { // Should have reverted to the older version - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_true(b1.isActive); @@ -948,10 +1000,10 @@ function check_test_19() { do_check_eq(getInstallReason(), ADDON_INSTALL); do_check_eq(getStartupReason(), ADDON_INSTALL); - do_check_eq(getShutdownNewVersion(), undefined); - do_check_eq(getUninstallNewVersion(), undefined); - do_check_eq(getInstallOldVersion(), undefined); - do_check_eq(getStartupOldVersion(), undefined); + do_check_eq(getShutdownNewVersion(), 0); + do_check_eq(getUninstallNewVersion(), 0); + do_check_eq(getInstallOldVersion(), 0); + do_check_eq(getStartupOldVersion(), 0); do_check_bootstrappedPref(run_test_20); }); @@ -960,17 +1012,18 @@ function check_test_19() { // Check that a new profile extension detected at startup replaces the non-profile // one function run_test_20() { + resetPrefs(); shutdownManager(); manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, - ID1); + "bootstrap1@tests.mozilla.org"); startupManager(); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { // Should have installed and started - BootstrapMonitor.checkAddonInstalled(ID1, "2.0"); - BootstrapMonitor.checkAddonStarted(ID1, "2.0"); + do_check_eq(getInstalledVersion(), 2); + do_check_eq(getActiveVersion(), 2); do_check_neq(b1, null); do_check_eq(b1.version, "2.0"); do_check_true(b1.isActive); @@ -980,10 +1033,10 @@ function run_test_20() { do_check_eq(getInstallReason(), ADDON_UPGRADE); do_check_eq(getStartupReason(), APP_STARTUP); - do_check_eq(getShutdownNewVersion(), undefined); + do_check_eq(getShutdownNewVersion(), 0); do_check_eq(getUninstallNewVersion(), 2); do_check_eq(getInstallOldVersion(), 1); - do_check_eq(getStartupOldVersion(), undefined); + do_check_eq(getStartupOldVersion(), 0); do_execute_soon(run_test_21); }); @@ -991,42 +1044,39 @@ function run_test_20() { // Check that a detected removal reveals the non-profile one function run_test_21() { + resetPrefs(); shutdownManager(); - do_check_eq(getShutdownReason(), APP_SHUTDOWN); - do_check_eq(getShutdownNewVersion(), undefined); - - manuallyUninstall(profileDir, ID1); - BootstrapMonitor.clear(ID1); + manuallyUninstall(profileDir, "bootstrap1@tests.mozilla.org"); startupManager(); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { // Should have installed and started - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_true(b1.isActive); + do_check_eq(getShutdownReason(), APP_SHUTDOWN); + do_check_eq(getShutdownNewVersion(), 0); + // This won't be set as the bootstrap script was gone so we couldn't // uninstall it properly - do_check_eq(getUninstallReason(), undefined); - do_check_eq(getUninstallNewVersion(), undefined); + do_check_eq(getUninstallReason(), -1); + do_check_eq(getUninstallNewVersion(), -1); do_check_eq(getInstallReason(), ADDON_DOWNGRADE); do_check_eq(getInstallOldVersion(), 2); do_check_eq(getStartupReason(), APP_STARTUP); - do_check_eq(getStartupOldVersion(), undefined); + do_check_eq(getStartupOldVersion(), 0); do_check_bootstrappedPref(function() { - shutdownManager(); + manuallyUninstall(userExtDir, "bootstrap1@tests.mozilla.org"); - manuallyUninstall(userExtDir, ID1); - BootstrapMonitor.clear(ID1); - - startupManager(false); + restartManager(); run_test_22(); }); }); @@ -1037,50 +1087,50 @@ function run_test_22() { shutdownManager(); let file = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, - ID1); + "bootstrap1@tests.mozilla.org"); // Make it look old so changes are detected setExtensionModifiedTime(file, file.lastModifiedTime - 5000); startupManager(); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { // Should have installed and started - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_true(b1.isActive); + resetPrefs(); shutdownManager(); - do_check_eq(getShutdownReason(), APP_SHUTDOWN); - do_check_eq(getShutdownNewVersion(), undefined); - - manuallyUninstall(profileDir, ID1); - BootstrapMonitor.clear(ID1); + manuallyUninstall(profileDir, "bootstrap1@tests.mozilla.org"); manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, - ID1); + "bootstrap1@tests.mozilla.org"); startupManager(); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { // Should have installed and started - BootstrapMonitor.checkAddonInstalled(ID1, "2.0"); - BootstrapMonitor.checkAddonStarted(ID1, "2.0"); + do_check_eq(getInstalledVersion(), 2); + do_check_eq(getActiveVersion(), 2); do_check_neq(b1, null); do_check_eq(b1.version, "2.0"); do_check_true(b1.isActive); + do_check_eq(getShutdownReason(), APP_SHUTDOWN); + do_check_eq(getShutdownNewVersion(), 0); + // This won't be set as the bootstrap script was gone so we couldn't // uninstall it properly - do_check_eq(getUninstallReason(), undefined); - do_check_eq(getUninstallNewVersion(), undefined); + do_check_eq(getUninstallReason(), -1); + do_check_eq(getUninstallNewVersion(), -1); do_check_eq(getInstallReason(), ADDON_UPGRADE); do_check_eq(getInstallOldVersion(), 1); do_check_eq(getStartupReason(), APP_STARTUP); - do_check_eq(getStartupOldVersion(), undefined); + do_check_eq(getStartupOldVersion(), 0); do_check_bootstrappedPref(function() { b1.uninstall(); @@ -1117,11 +1167,11 @@ function run_test_23() { do_check_false(install.addon.hasResource("foo.bar")); do_check_eq(install.addon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_INSTALL, 0); - do_check_not_in_crash_annotation(ID1, "1.0"); + do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); let addon = install.addon; prepare_test({ - [ID1]: [ + "bootstrap1@tests.mozilla.org": [ ["onInstalling", false], "onInstalled" ] @@ -1143,30 +1193,30 @@ function check_test_23() { // doesn't require a restart. do_check_eq(installs.length, 0); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_execute_soon(function test_23_after_startup() { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_false(b1.appDisabled); do_check_false(b1.userDisabled); do_check_true(b1.isActive); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_eq(getStartupReason(), ADDON_INSTALL); - do_check_eq(getStartupOldVersion(), undefined); + do_check_eq(getStartupOldVersion(), 0); do_check_true(b1.hasResource("install.rdf")); do_check_true(b1.hasResource("bootstrap.js")); do_check_false(b1.hasResource("foo.bar")); - do_check_in_crash_annotation(ID1, "1.0"); + do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); - let dir = do_get_addon_root_uri(profileDir, ID1); + let dir = do_get_addon_root_uri(profileDir, "bootstrap1@tests.mozilla.org"); do_check_eq(b1.getResourceURI("bootstrap.js").spec, dir + "bootstrap.js"); AddonManager.getAddonsWithOperationsByTypes(null, callback_soon(function(list) { do_check_eq(list.length, 0); restartManager(); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { b1.uninstall(); restartManager(); @@ -1180,42 +1230,45 @@ function check_test_23() { // Tests that we recover from a broken preference function run_test_24() { + resetPrefs(); do_print("starting 24"); - Promise.all([BootstrapMonitor.promiseAddonStartup(ID2), - promiseInstallAllFiles([do_get_addon("test_bootstrap1_1"), do_get_addon("test_bootstrap2_1")])]) + Promise.all([promisePref("bootstraptest2.active_version"), + promiseInstall([do_get_addon("test_bootstrap1_1"), do_get_addon("test_bootstrap2_1")])]) .then(function test_24_pref() { do_print("test 24 got prefs"); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); - BootstrapMonitor.checkAddonInstalled(ID2, "1.0"); - BootstrapMonitor.checkAddonStarted(ID2, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); + do_check_eq(getInstalledVersion2(), 1); + do_check_eq(getActiveVersion2(), 1); + + resetPrefs(); restartManager(); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); - BootstrapMonitor.checkAddonInstalled(ID2, "1.0"); - BootstrapMonitor.checkAddonStarted(ID2, "1.0"); + do_check_eq(getInstalledVersion(), -1); + do_check_eq(getActiveVersion(), 1); + do_check_eq(getInstalledVersion2(), -1); + do_check_eq(getActiveVersion2(), 1); shutdownManager(); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); - BootstrapMonitor.checkAddonInstalled(ID2, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID2); + do_check_eq(getInstalledVersion(), -1); + do_check_eq(getActiveVersion(), 0); + do_check_eq(getInstalledVersion2(), -1); + do_check_eq(getActiveVersion2(), 0); - // Break the preference + // Break the preferece let bootstrappedAddons = JSON.parse(Services.prefs.getCharPref("extensions.bootstrappedAddons")); - bootstrappedAddons[ID1].descriptor += "foo"; + bootstrappedAddons["bootstrap1@tests.mozilla.org"].descriptor += "foo"; Services.prefs.setCharPref("extensions.bootstrappedAddons", JSON.stringify(bootstrappedAddons)); startupManager(false); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); - BootstrapMonitor.checkAddonInstalled(ID2, "1.0"); - BootstrapMonitor.checkAddonStarted(ID2, "1.0"); + do_check_eq(getInstalledVersion(), -1); + do_check_eq(getActiveVersion(), 1); + do_check_eq(getInstalledVersion2(), -1); + do_check_eq(getActiveVersion2(), 1); run_test_25(); }); @@ -1224,17 +1277,17 @@ function run_test_24() { // Tests that updating from a bootstrappable add-on to a normal add-on calls // the uninstall method function run_test_25() { - BootstrapMonitor.promiseAddonStartup(ID1).then(function test_25_after_pref() { + waitForPref("bootstraptest.startup_reason", function test_25_after_pref() { do_print("test 25 pref change detected"); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); installAllFiles([do_get_addon("test_bootstrap1_4")], function() { // Needs a restart to complete this so the old version stays running - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_true(b1.isActive); @@ -1242,12 +1295,12 @@ function run_test_25() { restartManager(); - BootstrapMonitor.checkAddonNotInstalled(ID1); + do_check_eq(getInstalledVersion(), 0); do_check_eq(getUninstallReason(), ADDON_UPGRADE); do_check_eq(getUninstallNewVersion(), 4); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getActiveVersion(), 0); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "4.0"); do_check_true(b1.isActive); @@ -1268,10 +1321,10 @@ function run_test_25() { function run_test_26() { installAllFiles([do_get_addon("test_bootstrap1_1")], function() { // Needs a restart to complete this - BootstrapMonitor.checkAddonNotInstalled(ID1); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 0); + do_check_eq(getActiveVersion(), 0); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "4.0"); do_check_true(b1.isActive); @@ -1279,12 +1332,12 @@ function run_test_26() { restartManager(); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); do_check_eq(getInstallReason(), ADDON_DOWNGRADE); do_check_eq(getInstallOldVersion(), 4); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getActiveVersion(), 1); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_true(b1.isActive); @@ -1299,23 +1352,23 @@ function run_test_26() { // Tests that updating from a bootstrappable add-on to a normal add-on while // disabled calls the uninstall method function run_test_27() { - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); b1.userDisabled = true; do_check_eq(b1.version, "1.0"); do_check_false(b1.isActive); do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); installAllFiles([do_get_addon("test_bootstrap1_4")], function() { // Updating disabled things happens immediately - BootstrapMonitor.checkAddonNotInstalled(ID1); + do_check_eq(getInstalledVersion(), 0); do_check_eq(getUninstallReason(), ADDON_UPGRADE); do_check_eq(getUninstallNewVersion(), 4); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getActiveVersion(), 0); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "4.0"); do_check_false(b1.isActive); @@ -1323,10 +1376,10 @@ function run_test_27() { restartManager(); - BootstrapMonitor.checkAddonNotInstalled(ID1); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 0); + do_check_eq(getActiveVersion(), 0); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "4.0"); do_check_false(b1.isActive); @@ -1345,12 +1398,12 @@ function run_test_28() { installAllFiles([do_get_addon("test_bootstrap1_1")], function() { do_execute_soon(function bootstrap_disabled_downgrade_check() { // Doesn't need a restart to complete this - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); do_check_eq(getInstallReason(), ADDON_DOWNGRADE); do_check_eq(getInstallOldVersion(), 4); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getActiveVersion(), 0); - AddonManager.getAddonByID(ID1, callback_soon(function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) { do_check_neq(b1, null); do_check_eq(b1.version, "1.0"); do_check_false(b1.isActive); @@ -1359,18 +1412,18 @@ function run_test_28() { restartManager(); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonNotStarted(ID1); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 0); - AddonManager.getAddonByID(ID1, function(b1) { + AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) { do_check_neq(b1, null); do_check_true(b1.userDisabled); b1.userDisabled = false; do_check_eq(b1.version, "1.0"); do_check_true(b1.isActive); do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE); - BootstrapMonitor.checkAddonInstalled(ID1, "1.0"); - BootstrapMonitor.checkAddonStarted(ID1, "1.0"); + do_check_eq(getInstalledVersion(), 1); + do_check_eq(getActiveVersion(), 1); do_check_bootstrappedPref(do_test_finished); }); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js index 6b12ec9b24e5..a6f9c8052311 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js @@ -19,8 +19,6 @@ userExtDir.append("extensions2"); userExtDir.append(gAppInfo.ID); registerDirectory("XREUSysExt", userExtDir.parent); -BootstrapMonitor.init(); - function TestProvider(result) { this.result = result; } @@ -52,6 +50,18 @@ function check_mapping(uri, id) { do_check_eq(val.value, id); } +function resetPrefs() { + Services.prefs.setIntPref("bootstraptest.active_version", -1); +} + +function waitForPref(aPref, aCallback) { + function prefChanged() { + Services.prefs.removeObserver(aPref, prefChanged); + aCallback(); + } + Services.prefs.addObserver(aPref, prefChanged, false); +} + function getActiveVersion() { return Services.prefs.getIntPref("bootstraptest.active_version"); } @@ -59,6 +69,8 @@ function getActiveVersion() { function run_test() { do_test_pending(); + resetPrefs(); + run_test_early(); } @@ -136,7 +148,7 @@ function run_test_1() { let uri = addon.getResourceURI("."); check_mapping(uri, addon.id); - BootstrapMonitor.promiseAddonStartup("bootstrap1@tests.mozilla.org").then(function() { + waitForPref("bootstraptest.active_version", function() { run_test_2(uri); }); }); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js index 8521943d0878..22f47f8f2f11 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js @@ -5,8 +5,6 @@ const PREF_SYSTEM_ADDON_SET = "extensions.systemAddonSet"; // Enable signature checks for these tests Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true); -BootstrapMonitor.init(); - const featureDir = FileUtils.getDir("ProfD", ["features"]); // Build the test sets @@ -63,7 +61,8 @@ function* check_installed(inProfile, ...versions) { do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SYSTEM); // Verify the add-on actually started - BootstrapMonitor.checkAddonStarted(id, versions[i]); + let installed = Services.prefs.getCharPref("bootstraptest." + id + ".active_version"); + do_check_eq(installed, versions[i]); } else { if (inProfile) { @@ -75,12 +74,12 @@ function* check_installed(inProfile, ...versions) { do_check_true(!addon || !addon.isActive); } - BootstrapMonitor.checkAddonNotStarted(id); - - if (addon) - BootstrapMonitor.checkAddonInstalled(id); - else - BootstrapMonitor.checkAddonNotInstalled(id); + try { + Services.prefs.getCharPref("bootstraptest." + id + ".active_version"); + do_throw("Expected pref to be missing"); + } + catch (e) { + } } } } @@ -187,9 +186,6 @@ add_task(function* test_skips_additional() { add_task(function* test_revert() { manuallyUninstall(featureDir, "system2@tests.mozilla.org"); - // With the add-on physically gone from disk we won't see uninstall events - BootstrapMonitor.clear("system2@tests.mozilla.org"); - startupManager(false); // With system add-on 2 gone the updated set is now invalid so it reverts to @@ -262,7 +258,7 @@ add_task(function* test_bad_app_cert() { // Add-on will still be present just not active let addon = yield promiseAddonByID("system1@tests.mozilla.org"); do_check_neq(addon, null); - do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN); + do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED); yield check_installed(false, null, null, "1.0"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js index 448ec2efb52a..f5cca31f9717 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js @@ -9,9 +9,7 @@ Components.utils.import("resource://testing-common/httpd.js"); const { computeHash } = Components.utils.import("resource://gre/modules/addons/ProductAddonChecker.jsm"); // Enable signature checks for these tests -Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true); - -BootstrapMonitor.init(); +//Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true); const featureDir = FileUtils.getDir("ProfD", ["features"]); @@ -144,8 +142,6 @@ function* check_installed(inProfile, ...versions) { let addon = yield promiseAddonByID(id); if (versions[i]) { - do_print(`Checking state of add-on ${id}, expecting version ${versions[i]}`); - // Add-on should be installed do_check_neq(addon, null); do_check_eq(addon.version, versions[i]); @@ -163,14 +159,13 @@ function* check_installed(inProfile, ...versions) { do_check_true(uri instanceof AM_Ci.nsIFileURL); do_check_eq(uri.file.path, file.path); - do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SYSTEM); + //do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SYSTEM); // Verify the add-on actually started - BootstrapMonitor.checkAddonStarted(id, versions[i]); + let installed = Services.prefs.getCharPref("bootstraptest." + id + ".active_version"); + do_check_eq(installed, versions[i]); } else { - do_print(`Checking state of add-on ${id}, expecting it to be missing`); - if (inProfile) { // Add-on should not be installed do_check_eq(addon, null); @@ -180,12 +175,12 @@ function* check_installed(inProfile, ...versions) { do_check_true(!addon || !addon.isActive); } - BootstrapMonitor.checkAddonNotStarted(id); - - if (addon) - BootstrapMonitor.checkAddonInstalled(id); - else - BootstrapMonitor.checkAddonNotInstalled(id); + try { + Services.prefs.getCharPref("bootstraptest." + id + ".active_version"); + do_throw("Expected pref to be missing"); + } + catch (e) { + } } } } @@ -333,9 +328,9 @@ const TESTS = { // Correct sizes and hashes should work checkSizeHash: { updateList: [ - { id: "system2@tests.mozilla.org", version: "3.0", path: "system2_3.xpi", size: 4672 }, - { id: "system3@tests.mozilla.org", version: "3.0", path: "system3_3.xpi", hashFunction: "sha1", hashValue: "2df604b37b13766c0e04f1b7f59800e038f46cd5" }, - { id: "system5@tests.mozilla.org", version: "1.0", path: "system5_1.xpi", size: 4671, hashFunction: "sha1", hashValue: "f13dcaa8bfacaa222189bcbb0074972c05ceb621" } + { id: "system2@tests.mozilla.org", version: "3.0", path: "system2_3.xpi", size: 858 }, + { id: "system3@tests.mozilla.org", version: "3.0", path: "system3_3.xpi", hashFunction: "sha1", hashValue: "105a4c49bd513ebd30594e380c19e86bba1f83e2" }, + { id: "system5@tests.mozilla.org", version: "1.0", path: "system5_1.xpi", size: 857, hashFunction: "sha1", hashValue: "664e9218be3c9acbb9029e715c1e5d2fbb4ea2cc" } ], finalState: [true, null, "3.0", "3.0", null, "1.0"] },