Bug 1459998: Part 1 - Rewrite tests not to use async helpers. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Tue, 08 May 2018 14:12:27 -0700
changeset 792874 c69643e6b63fac734025c17364553422d7489b19
parent 792873 25d8087454c6b6b9d7d89bae0442de2760f25d24
child 792875 9b5f56fe14b7251ee90bd204d59a9d5462162d86
push id109197
push usermaglione.k@gmail.com
push dateTue, 08 May 2018 23:28:26 +0000
reviewersaswan
bugs1459998
milestone62.0a1
Bug 1459998: Part 1 - Rewrite tests not to use async helpers. r?aswan MozReview-Commit-ID: CF2UGYK7wMr
toolkit/mozapps/extensions/test/xpcshell/head_addons.js
toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js
toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js
toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js
toolkit/mozapps/extensions/test/xpcshell/test_bad_json.js
toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js
toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js
toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js
toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js
toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js
toolkit/mozapps/extensions/test/xpcshell/test_corruptfile.js
toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js
toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js
toolkit/mozapps/extensions/test/xpcshell/test_distribution.js
toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js
toolkit/mozapps/extensions/test/xpcshell/test_error.js
toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js
toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
toolkit/mozapps/extensions/test/xpcshell/test_general.js
toolkit/mozapps/extensions/test/xpcshell/test_getresource.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js
toolkit/mozapps/extensions/test/xpcshell/test_isReady.js
toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
toolkit/mozapps/extensions/test/xpcshell/test_locale.js
toolkit/mozapps/extensions/test/xpcshell/test_manifest_locales.js
toolkit/mozapps/extensions/test/xpcshell/test_moved_extension_metadata.js
toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js
toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js
toolkit/mozapps/extensions/test/xpcshell/test_onPropertyChanged_appDisabled.js
toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
toolkit/mozapps/extensions/test/xpcshell/test_permissions.js
toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js
toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js
toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js
toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js
toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js
toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js
toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
toolkit/mozapps/extensions/test/xpcshell/test_proxy.js
toolkit/mozapps/extensions/test/xpcshell/test_registry.js
toolkit/mozapps/extensions/test/xpcshell/test_reload.js
toolkit/mozapps/extensions/test/xpcshell/test_safemode.js
toolkit/mozapps/extensions/test/xpcshell/test_seen.js
toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js
toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js
toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js
toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js
toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js
toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js
toolkit/mozapps/extensions/test/xpcshell/test_startup.js
toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js
toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js
toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js
toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update_blank.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update_checkSizeHash.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update_fail.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update_newset.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update_overlapping.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update_upgrades.js
toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
toolkit/mozapps/extensions/test/xpcshell/test_types.js
toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js
toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js
toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js
toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js
toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js
toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
toolkit/mozapps/extensions/test/xpcshell/test_webextension_install_syntax_error.js
toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js
toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -74,16 +74,17 @@ XPCOMUtils.defineLazyServiceGetter(this,
 const {
   awaitPromise,
   createAppInfo,
   createHttpServer,
   createInstallRDF,
   createTempWebExtensionFile,
   createUpdateRDF,
   getFileForAddon,
+  manuallyInstall,
   manuallyUninstall,
   overrideBuiltIns,
   promiseAddonEvent,
   promiseCompleteAllInstalls,
   promiseCompleteInstall,
   promiseConsoleOutput,
   promiseFindAddonUpdates,
   promiseInstallAllFiles,
@@ -94,21 +95,16 @@ const {
   promiseStartupManager,
   promiseWebExtensionStartup,
   promiseWriteProxyFileToDir,
   registerDirectory,
   setExtensionModifiedTime,
   writeFilesToZip
 } = AddonTestUtils;
 
-function manuallyInstall(...args) {
-  return AddonTestUtils.awaitPromise(
-    AddonTestUtils.manuallyInstall(...args));
-}
-
 // WebExtension wrapper for ease of testing
 ExtensionTestUtils.init(this);
 
 AddonTestUtils.init(this);
 AddonTestUtils.overrideCertDB();
 
 Object.defineProperty(this, "gAppInfo", {
   get() {
@@ -1505,31 +1501,31 @@ async function getSystemAddonDirectories
  */
 async function setupSystemAddonConditions(setup, distroDir) {
   info("Clearing existing database.");
   Services.prefs.clearUserPref(PREF_SYSTEM_ADDON_SET);
   distroDir.leafName = "empty";
 
   let updateList = [];
   awaitPromise(overrideBuiltIns({ "system": updateList }));
-  startupManager();
+  await promiseStartupManager();
   await promiseShutdownManager();
 
   info("Setting up conditions.");
   await setup.setup();
 
   if (distroDir) {
     if (distroDir.path.endsWith("hidden")) {
       updateList = ["system1@tests.mozilla.org", "system2@tests.mozilla.org"];
     } else if (distroDir.path.endsWith("prefilled")) {
       updateList = ["system2@tests.mozilla.org", "system3@tests.mozilla.org"];
     }
   }
   awaitPromise(overrideBuiltIns({ "system": updateList }));
-  startupManager();
+  await promiseStartupManager();
 
   // Make sure the initial state is correct
   info("Checking initial state.");
   await checkInstalledSystemAddons(setup.initialState, distroDir);
 }
 
 /**
  * Verify state of system add-ons after installation.
@@ -1576,17 +1572,17 @@ async function verifySystemAddonState(in
   if (distroDir) {
     if (distroDir.path.endsWith("hidden")) {
       updateList = ["system1@tests.mozilla.org", "system2@tests.mozilla.org"];
     } else if (distroDir.path.endsWith("prefilled")) {
       updateList = ["system2@tests.mozilla.org", "system3@tests.mozilla.org"];
     }
   }
   awaitPromise(overrideBuiltIns({ "system": updateList }));
-  startupManager();
+  await promiseStartupManager();
   await checkInstalledSystemAddons(finalState, distroDir);
 }
 
 /**
  * Run system add-on tests and compare the results against a set of expected conditions.
  *
  * @param {String} setupName - name of the current setup conditions.
  * @param {Object<function, Array<Object>} setup -  Defines the set of initial conditions to run each test against. Each should
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js
@@ -484,17 +484,17 @@ async function check_initialized_cache(a
   let cacheEnabled = Services.prefs.getBoolPref(PREF_GETADDONS_CACHE_ENABLED);
   await check_cache(aExpectedToFind, !cacheEnabled);
 }
 
 add_task(async function setup() {
   // Setup for test
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
 
-  startupManager();
+  await promiseStartupManager();
 
   // Install XPI add-ons
   await promiseInstallAllFiles(ADDON_FILES);
   await promiseRestartManager();
 
   gServer = AddonTestUtils.createHttpServer({hosts: [HOST]});
   gServer.registerDirectory("/data/", do_get_file("data"));
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
@@ -18,19 +18,19 @@ function dummy(id) {
   };
 }
 
 function hasPermission(aAddon, aPerm) {
   var perm = AddonManager["PERM_CAN_" + aPerm.toUpperCase()];
   return !!(aAddon.permissions & perm);
 }
 
-async function run_test() {
+add_task(async function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
-  startupManager();
+  await promiseStartupManager();
 
   Services.prefs.setIntPref("lightweightThemes.maxUsedThemes", 8);
 
   let {LightweightThemeManager: ltm} = ChromeUtils.import("resource://gre/modules/LightweightThemeManager.jsm", {});
 
   Assert.equal(typeof ltm, "object");
   Assert.equal(typeof ltm.usedThemes, "object");
   Assert.equal(ltm.usedThemes.length, 1);
@@ -529,18 +529,16 @@ async function run_test() {
   Assert.equal([...ltm._builtInThemes].length, 0);
   Assert.equal(ltm.usedThemes.length, 0);
 
   ltm.addBuiltInTheme(dummy("builtInTheme0"));
   ltm.addBuiltInTheme(dummy("builtInTheme1"));
   Assert.equal([...ltm._builtInThemes].length, 2);
   Assert.equal(ltm.usedThemes.length, 2);
 
-  do_test_pending();
-
   let builtInThemeAddon = await AddonManager.getAddonByID("builtInTheme0@personas.mozilla.org");
   Assert.equal(hasPermission(builtInThemeAddon, "uninstall"), false);
   Assert.equal(hasPermission(builtInThemeAddon, "disable"), false);
   Assert.equal(hasPermission(builtInThemeAddon, "enable"), true);
 
   ltm.currentTheme = dummy("x0");
   Assert.equal([...ltm._builtInThemes].length, 2);
   Assert.equal(ltm.usedThemes.length, 3);
@@ -572,11 +570,9 @@ async function run_test() {
   Assert.equal(ltm.usedThemes.length, 1);
 
   Assert.ok(ltm.forgetBuiltInTheme("builtInTheme1"));
   Assert.ok(!ltm.forgetBuiltInTheme("not-an-existing-theme-id"));
 
   Assert.equal([...ltm._builtInThemes].length, 0);
   Assert.equal(ltm.usedThemes.length, 0);
   Assert.equal(ltm.currentTheme, null);
-
-  do_test_finished();
-}
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js
@@ -17,69 +17,71 @@ function run_test() {
   // Shut down the add-on manager after all tests run.
   registerCleanupFunction(promiseShutdownManager);
   // Kick off the task-based tests...
   run_next_test();
 }
 
 // Use bootstrap extensions so the changes will be immediate.
 // A packed extension, to be enabled
-writeInstallRDFToXPI({
-  id: "packed-enabled@tests.mozilla.org",
-  version: "1.0",
-  bootstrap: true,
-  targetApplications: [{
-    id: "xpcshell@tests.mozilla.org",
-    minVersion: "1",
-    maxVersion: "1"
-  }],
-  name: "Packed, Enabled",
-}, profileDir);
+add_task(async function setup() {
+  await promiseWriteInstallRDFToXPI({
+    id: "packed-enabled@tests.mozilla.org",
+    version: "1.0",
+    bootstrap: true,
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "1",
+      maxVersion: "1"
+    }],
+    name: "Packed, Enabled",
+  }, profileDir);
 
-// Packed, will be disabled
-writeInstallRDFToXPI({
-  id: "packed-disabled@tests.mozilla.org",
-  version: "1.0",
-  bootstrap: true,
-  targetApplications: [{
-    id: "xpcshell@tests.mozilla.org",
-    minVersion: "1",
-    maxVersion: "1"
-  }],
-  name: "Packed, Disabled",
-}, profileDir);
+  // Packed, will be disabled
+  await promiseWriteInstallRDFToXPI({
+    id: "packed-disabled@tests.mozilla.org",
+    version: "1.0",
+    bootstrap: true,
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "1",
+      maxVersion: "1"
+    }],
+    name: "Packed, Disabled",
+  }, profileDir);
 
-// Unpacked, enabled
-writeInstallRDFToDir({
-  id: "unpacked-enabled@tests.mozilla.org",
-  version: "1.0",
-  bootstrap: true,
-  unpack: true,
-  targetApplications: [{
-    id: "xpcshell@tests.mozilla.org",
-    minVersion: "1",
-    maxVersion: "1"
-  }],
-  name: "Unpacked, Enabled",
-}, profileDir, undefined, "extraFile.js");
+  // Unpacked, enabled
+  await promiseWriteInstallRDFToDir({
+    id: "unpacked-enabled@tests.mozilla.org",
+    version: "1.0",
+    bootstrap: true,
+    unpack: true,
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "1",
+      maxVersion: "1"
+    }],
+    name: "Unpacked, Enabled",
+  }, profileDir, undefined, "extraFile.js");
 
 
-// Unpacked, disabled
-writeInstallRDFToDir({
-  id: "unpacked-disabled@tests.mozilla.org",
-  version: "1.0",
-  bootstrap: true,
-  unpack: true,
-  targetApplications: [{
-    id: "xpcshell@tests.mozilla.org",
-    minVersion: "1",
-    maxVersion: "1"
-  }],
-  name: "Unpacked, disabled",
-}, profileDir, undefined, "extraFile.js");
+  // Unpacked, disabled
+  await promiseWriteInstallRDFToDir({
+    id: "unpacked-disabled@tests.mozilla.org",
+    version: "1.0",
+    bootstrap: true,
+    unpack: true,
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "1",
+      maxVersion: "1"
+    }],
+    name: "Unpacked, disabled",
+  }, profileDir, undefined, "extraFile.js");
+});
 
 // Keep track of the last time stamp we've used, so that we can keep moving
 // it forward (if we touch two different files in the same add-on with the same
 // timestamp we may not consider the change significant)
 var lastTimestamp = Date.now();
 
 /*
  * Helper function to touch a file and then test whether we detect the change.
@@ -105,17 +107,17 @@ function getXS() {
 
 async function getXSJSON() {
   await AddonTestUtils.loadAddonsList(true);
 
   return aomStartup.readStartupData();
 }
 
 add_task(async function detect_touches() {
-  startupManager();
+  await promiseStartupManager();
   let [/* pe */, pd, /* ue */, ud] = await promiseAddonsByIDs([
          "packed-enabled@tests.mozilla.org",
          "packed-disabled@tests.mozilla.org",
          "unpacked-enabled@tests.mozilla.org",
          "unpacked-disabled@tests.mozilla.org"
          ]);
 
   info("Disable test add-ons");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js
@@ -6,27 +6,27 @@
 
 // The test extension uses an insecure update url.
 Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
 
 var testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   testserver.registerDirectory("/addons/", do_get_file("addons"));
   testserver.registerDirectory("/data/", do_get_file("data"));
 
-  startupManager();
+  await promiseStartupManager();
 
   do_test_pending();
   run_test_1();
-}
+});
 
 function end_test() {
   do_test_finished();
 }
 
 // Verify that with no add-ons installed the background update notifications get
 // called
 async function run_test_1() {
@@ -40,44 +40,44 @@ async function run_test_1() {
   }, "addons-background-update-complete");
 
   // Trigger the background update timer handler
   gInternalManager.notify(null);
 }
 
 // Verify that with two add-ons installed both of which claim to have updates
 // available we get the notification after both updates attempted to start
-function run_test_2() {
-  writeInstallRDFForExtension({
+async function run_test_2() {
+  await promiseWriteInstallRDFForExtension({
     id: "addon1@tests.mozilla.org",
     version: "1.0",
     updateURL: "http://example.com/data/test_backgroundupdate.json",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test Addon 1",
   }, profileDir);
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "addon2@tests.mozilla.org",
     version: "1.0",
     updateURL: "http://example.com/data/test_backgroundupdate.json",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test Addon 2",
   }, profileDir);
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "addon3@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
@@ -86,17 +86,17 @@ function run_test_2() {
 
   // Disable rcwn to make cache behavior deterministic.
   Services.prefs.setBoolPref("network.http.rcwn.enabled", false);
 
   // Background update uses a different pref, if set
   Services.prefs.setCharPref("extensions.update.background.url",
                              "http://example.com/data/test_backgroundupdate.json");
 
-  restartManager();
+  await promiseRestartManager();
 
   let installCount = 0;
   let completeCount = 0;
   let sawCompleteNotification = false;
 
   Services.obs.addObserver(function observer() {
     Services.obs.removeObserver(observer, "addons-background-update-complete");
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bad_json.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bad_json.js
@@ -19,17 +19,17 @@ var addon1 = {
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
 add_task(async function() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   // This addon will be auto-installed at startup
-  writeInstallRDFForExtension(addon1, profileDir);
+  await promiseWriteInstallRDFForExtension(addon1, profileDir);
 
   await promiseStartupManager();
   await promiseShutdownManager();
 
   // First startup/shutdown finished
   // Replace the JSON store with something bogus
   await saveJSON({not: "what we expect to find"}, gExtensionsJSON.path);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js
@@ -66,76 +66,76 @@ function end_test() {
 }
 
 async function run_test() {
   do_test_pending();
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
 
   // Should get blocked by name
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "block1@tests.mozilla.org",
     version: "1.0",
     name: "Mozilla Corp.",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "3"
     }]
   }, profileDir);
 
   // Should get blocked by all the attributes.
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "block2@tests.mozilla.org",
     version: "1.0",
     name: "Moz-addon",
     bootstrap: true,
     creator: "Dangerous",
     homepageURL: "www.extension.dangerous.com",
     updateURL: "www.extension.dangerous.com/update.rdf",
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "3"
     }]
   }, profileDir);
 
   // Fails to get blocked because of a different ID even though other
   // attributes match against a blocklist entry.
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "block3@tests.mozilla.org",
     version: "1.0",
     name: "Moz-addon",
     bootstrap: true,
     creator: "Dangerous",
     homepageURL: "www.extensions.dangerous.com",
     updateURL: "www.extension.dangerous.com/update.rdf",
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "3"
     }]
   }, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [a1, a2, a3] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
                                                         "block2@tests.mozilla.org",
                                                         "block3@tests.mozilla.org"]);
   Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   Assert.equal(a3.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
 
   run_test_1();
 }
 
 function run_test_1() {
   load_blocklist("test_blocklist_metadata_filters_1.xml", async function() {
-    restartManager();
+    await promiseRestartManager();
 
     let [a1, a2, a3] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
                                                           "block2@tests.mozilla.org",
                                                           "block3@tests.mozilla.org"]);
     Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
     Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_BLOCKED);
     Assert.equal(a3.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
     end_test();
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
@@ -66,29 +66,29 @@ function end_test() {
 }
 
 async function run_test() {
   do_test_pending();
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
 
   // Add 2 extensions
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "block1@tests.mozilla.org",
     version: "1.0",
     name: "Blocked add-on-1 with to-be-reset prefs",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "3"
     }]
   }, profileDir);
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "block2@tests.mozilla.org",
     version: "1.0",
     name: "Blocked add-on-2 with to-be-reset prefs",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "3"
@@ -96,34 +96,34 @@ async function run_test() {
   }, profileDir);
 
   // Pre-set the preferences that we expect to get reset.
   Services.prefs.setIntPref("test.blocklist.pref1", 15);
   Services.prefs.setIntPref("test.blocklist.pref2", 15);
   Services.prefs.setBoolPref("test.blocklist.pref3", true);
   Services.prefs.setBoolPref("test.blocklist.pref4", true);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Before blocklist is loaded.
   let [a1, a2] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
                                                     "block2@tests.mozilla.org"]);
   Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
 
   Assert.equal(Services.prefs.getIntPref("test.blocklist.pref1"), 15);
   Assert.equal(Services.prefs.getIntPref("test.blocklist.pref2"), 15);
   Assert.equal(Services.prefs.getBoolPref("test.blocklist.pref3"), true);
   Assert.equal(Services.prefs.getBoolPref("test.blocklist.pref4"), true);
   run_test_1();
 }
 
 function run_test_1() {
   load_blocklist("test_blocklist_prefs_1.xml", async function() {
-    restartManager();
+    await promiseRestartManager();
 
     // Blocklist changes should have applied and the prefs must be reset.
     let [a1, a2] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
                                                       "block2@tests.mozilla.org"]);
     Assert.notEqual(a1, null);
     Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
     Assert.notEqual(a2, null);
     Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_BLOCKED);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js
@@ -70,39 +70,39 @@ function end_test() {
 }
 
 
 async function run_test() {
   do_test_pending();
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "block1@tests.mozilla.org",
     version: "1.0",
     name: "RegExp blocked add-on",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "3"
     }]
   }, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [a1] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org"]);
   Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
 
   run_test_1();
 }
 
 function run_test_1() {
   load_blocklist("test_blocklist_regexp_1.xml", async function() {
-    restartManager();
+    await promiseRestartManager();
 
     let [a1] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org"]);
     Assert.notEqual(a1, null);
     Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
 
     end_test();
   });
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
@@ -698,23 +698,23 @@ function check_addon(aAddon, aExpectedVe
 }
 
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
   run_next_test();
 }
 
 add_task(async function init() {
-  writeInstallRDFForExtension(softblock1_1, profileDir);
-  writeInstallRDFForExtension(softblock2_1, profileDir);
-  writeInstallRDFForExtension(softblock3_1, profileDir);
-  writeInstallRDFForExtension(softblock4_1, profileDir);
-  writeInstallRDFForExtension(hardblock_1, profileDir);
-  writeInstallRDFForExtension(regexpblock_1, profileDir);
-  startupManager();
+  await promiseWriteInstallRDFForExtension(softblock1_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_1, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_1, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_1, profileDir);
+  await promiseStartupManager();
 
   let [/* s1 */, /* s2 */, /* s3 */, s4, /* h, r */] = await promiseAddonsByIDs(ADDON_IDS);
   s4.userDisabled = true;
 });
 
 // Starts with add-ons unblocked and then switches application versions to
 // change add-ons to blocked and back
 add_task(async function run_app_update_test() {
@@ -838,17 +838,17 @@ add_task(async function update_schema_3(
   check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
   check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
 });
 
 add_task(async function update_schema_4() {
   await promiseShutdownManager();
 
   await changeXPIDBVersion(100);
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
@@ -952,30 +952,30 @@ add_task(async function run_addon_change
   check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
 });
 
 add_task(async function run_addon_change_2() {
   await promiseShutdownManager();
 
-  writeInstallRDFForExtension(softblock1_2, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock1_2, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_2.id), Date.now() + 10000);
-  writeInstallRDFForExtension(softblock2_2, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_2, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_2.id), Date.now() + 10000);
-  writeInstallRDFForExtension(softblock3_2, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_2, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_2.id), Date.now() + 10000);
-  writeInstallRDFForExtension(softblock4_2, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_2, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_2.id), Date.now() + 10000);
-  writeInstallRDFForExtension(hardblock_2, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_2, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_2.id), Date.now() + 10000);
-  writeInstallRDFForExtension(regexpblock_2, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_2, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_2.id), Date.now() + 10000);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s2, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s3, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s4, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(h, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
@@ -988,58 +988,58 @@ add_task(async function run_addon_change
   check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
 });
 
 add_task(async function run_addon_change_3() {
   await promiseRestartManager();
 
   await promiseShutdownManager();
 
-  writeInstallRDFForExtension(softblock1_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock1_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_3.id), Date.now() + 20000);
-  writeInstallRDFForExtension(softblock2_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_3.id), Date.now() + 20000);
-  writeInstallRDFForExtension(softblock3_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_3.id), Date.now() + 20000);
-  writeInstallRDFForExtension(softblock4_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_3.id), Date.now() + 20000);
-  writeInstallRDFForExtension(hardblock_3, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_3.id), Date.now() + 20000);
-  writeInstallRDFForExtension(regexpblock_3, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_3.id), Date.now() + 20000);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s4, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
   check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
 });
 
 add_task(async function run_addon_change_4() {
   await promiseShutdownManager();
 
-  writeInstallRDFForExtension(softblock1_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock1_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_1.id), Date.now() + 30000);
-  writeInstallRDFForExtension(softblock2_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_1.id), Date.now() + 30000);
-  writeInstallRDFForExtension(softblock3_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_1.id), Date.now() + 30000);
-  writeInstallRDFForExtension(softblock4_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_1.id), Date.now() + 30000);
-  writeInstallRDFForExtension(hardblock_1, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_1.id), Date.now() + 30000);
-  writeInstallRDFForExtension(regexpblock_1, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_1.id), Date.now() + 30000);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
@@ -1059,24 +1059,24 @@ add_task(async function run_addon_change
   getFileForAddon(profileDir, softblock3_1.id).remove(true);
   getFileForAddon(profileDir, softblock4_1.id).remove(true);
   getFileForAddon(profileDir, hardblock_1.id).remove(true);
   getFileForAddon(profileDir, regexpblock_1.id).remove(true);
 
   await promiseStartupManager();
   await promiseShutdownManager();
 
-  writeInstallRDFForExtension(softblock1_2, profileDir);
-  writeInstallRDFForExtension(softblock2_2, profileDir);
-  writeInstallRDFForExtension(softblock3_2, profileDir);
-  writeInstallRDFForExtension(softblock4_2, profileDir);
-  writeInstallRDFForExtension(hardblock_2, profileDir);
-  writeInstallRDFForExtension(regexpblock_2, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock1_2, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_2, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_2, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_2, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_2, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_2, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, /* s4 */, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s2, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s3, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(h, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
   check_addon(r, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
@@ -1088,57 +1088,57 @@ add_task(async function run_addon_change
   check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
 });
 
 add_task(async function addon_change_2_test_2() {
   await promiseRestartManager();
 
   await promiseShutdownManager();
 
-  writeInstallRDFForExtension(softblock1_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock1_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_3.id), Date.now() + 10000);
-  writeInstallRDFForExtension(softblock2_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_3.id), Date.now() + 10000);
-  writeInstallRDFForExtension(softblock3_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_3.id), Date.now() + 10000);
-  writeInstallRDFForExtension(softblock4_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_3.id), Date.now() + 10000);
-  writeInstallRDFForExtension(hardblock_3, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_3.id), Date.now() + 10000);
-  writeInstallRDFForExtension(regexpblock_3, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_3, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_3.id), Date.now() + 10000);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, /* s4 */, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
   check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
 });
 
 add_task(async function addon_change_2_test_3() {
   await promiseShutdownManager();
 
-  writeInstallRDFForExtension(softblock1_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock1_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_1.id), Date.now() + 20000);
-  writeInstallRDFForExtension(softblock2_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_1.id), Date.now() + 20000);
-  writeInstallRDFForExtension(softblock3_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_1.id), Date.now() + 20000);
-  writeInstallRDFForExtension(softblock4_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_1.id), Date.now() + 20000);
-  writeInstallRDFForExtension(hardblock_1, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_1.id), Date.now() + 20000);
-  writeInstallRDFForExtension(regexpblock_1, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_1, profileDir);
   setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_1.id), Date.now() + 20000);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
   check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
@@ -1185,24 +1185,24 @@ add_task(async function run_background_u
   getFileForAddon(profileDir, softblock3_1.id).remove(true);
   getFileForAddon(profileDir, softblock4_1.id).remove(true);
   getFileForAddon(profileDir, hardblock_1.id).remove(true);
   getFileForAddon(profileDir, regexpblock_1.id).remove(true);
 
   await promiseStartupManager();
   await promiseShutdownManager();
 
-  writeInstallRDFForExtension(softblock1_3, profileDir);
-  writeInstallRDFForExtension(softblock2_3, profileDir);
-  writeInstallRDFForExtension(softblock3_3, profileDir);
-  writeInstallRDFForExtension(softblock4_3, profileDir);
-  writeInstallRDFForExtension(hardblock_3, profileDir);
-  writeInstallRDFForExtension(regexpblock_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock1_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_3, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_3, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_3, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_3, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s2, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s3, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
   check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
@@ -1291,24 +1291,24 @@ add_task(async function run_manual_updat
   getFileForAddon(profileDir, softblock3_1.id).remove(true);
   getFileForAddon(profileDir, softblock4_1.id).remove(true);
   getFileForAddon(profileDir, hardblock_1.id).remove(true);
   getFileForAddon(profileDir, regexpblock_1.id).remove(true);
 
   await promiseStartupManager();
   await promiseShutdownManager();
 
-  writeInstallRDFForExtension(softblock1_1, profileDir);
-  writeInstallRDFForExtension(softblock2_1, profileDir);
-  writeInstallRDFForExtension(softblock3_1, profileDir);
-  writeInstallRDFForExtension(softblock4_1, profileDir);
-  writeInstallRDFForExtension(hardblock_1, profileDir);
-  writeInstallRDFForExtension(regexpblock_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock1_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock2_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock3_1, profileDir);
+  await promiseWriteInstallRDFForExtension(softblock4_1, profileDir);
+  await promiseWriteInstallRDFForExtension(hardblock_1, profileDir);
+  await promiseWriteInstallRDFForExtension(regexpblock_1, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
 
   check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
   check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
   check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
@@ -1356,17 +1356,17 @@ add_task(async function run_local_instal
 
   getFileForAddon(profileDir, softblock1_1.id).remove(true);
   getFileForAddon(profileDir, softblock2_1.id).remove(true);
   getFileForAddon(profileDir, softblock3_1.id).remove(true);
   getFileForAddon(profileDir, softblock4_1.id).remove(true);
   getFileForAddon(profileDir, hardblock_1.id).remove(true);
   getFileForAddon(profileDir, regexpblock_1.id).remove(true);
 
-  startupManager();
+  await promiseStartupManager();
 
   await promiseInstallAllFiles([
     XPIS.blocklist_soft1_1,
     XPIS.blocklist_soft2_1,
     XPIS.blocklist_soft3_1,
     XPIS.blocklist_soft4_1,
     XPIS.blocklist_hard1_1,
     XPIS.blocklist_regexp1_1,
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
@@ -497,18 +497,17 @@ add_task(async function test_7() {
   await checkBootstrappedPref();
 });
 
 // Test that a bootstrapped extension dropped into the profile loads properly
 // on startup and doesn't cause an EM restart
 add_task(async function test_8() {
   await promiseShutdownManager();
 
-  manuallyInstall(XPIS.test_bootstrap1_1, profileDir,
-                  ID1);
+  await manuallyInstall(XPIS.test_bootstrap1_1, profileDir, ID1);
 
   await promiseStartupManager();
 
   let b1 = await AddonManager.getAddonByID(ID1);
   notEqual(b1, null);
   equal(b1.version, "1.0");
   ok(!b1.appDisabled);
   ok(!b1.userDisabled);
@@ -672,18 +671,17 @@ add_task(async function test_11() {
   await checkBootstrappedPref();
 });
 
 // Tests that bootstrapped extensions are correctly loaded even if the app is
 // upgraded at the same time
 add_task(async function test_12() {
   await promiseShutdownManager();
 
-  manuallyInstall(XPIS.test_bootstrap1_1, profileDir,
-                  ID1);
+  await manuallyInstall(XPIS.test_bootstrap1_1, profileDir, ID1);
 
   await promiseStartupManager();
 
   let b1 = await AddonManager.getAddonByID(ID1);
   notEqual(b1, null);
   equal(b1.version, "1.0");
   ok(!b1.appDisabled);
   ok(!b1.userDisabled);
@@ -766,18 +764,17 @@ add_task(async function test_13() {
 
 // Tests that a bootstrapped extension with an invalid target application entry
 // does not get loaded when detected during startup
 add_task(async function test_14() {
   await promiseRestartManager();
 
   await promiseShutdownManager();
 
-  manuallyInstall(XPIS.test_bootstrap1_3, profileDir,
-                  ID1);
+  await manuallyInstall(XPIS.test_bootstrap1_3, profileDir, ID1);
 
   await promiseStartupManager();
 
   let b1 = await AddonManager.getAddonByID(ID1);
   notEqual(b1, null);
   equal(b1.version, "3.0");
   ok(b1.appDisabled);
   ok(!b1.userDisabled);
@@ -906,18 +903,17 @@ add_task(async function test_16() {
   let b1_3 = await AddonManager.getAddonByID(ID1);
   b1_3.uninstall();
 });
 
 // Check that a bootstrapped extension in a non-profile location is loaded
 add_task(async function test_17() {
   await promiseShutdownManager();
 
-  manuallyInstall(XPIS.test_bootstrap1_1, userExtDir,
-                  ID1);
+  await manuallyInstall(XPIS.test_bootstrap1_1, userExtDir, ID1);
 
   await promiseStartupManager();
 
   let b1 = await AddonManager.getAddonByID(ID1);
   // Should have installed and started
   BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
   BootstrapMonitor.checkAddonStarted(ID1, "1.0");
   notEqual(b1, null);
@@ -997,18 +993,17 @@ add_task(async function test_19() {
   await checkBootstrappedPref();
 });
 
 // Check that a new profile extension detected at startup replaces the non-profile
 // one
 add_task(async function test_20() {
   await promiseShutdownManager();
 
-  manuallyInstall(XPIS.test_bootstrap1_2, profileDir,
-                  ID1);
+  await manuallyInstall(XPIS.test_bootstrap1_2, profileDir, ID1);
 
   await promiseStartupManager();
 
   let b1 = await AddonManager.getAddonByID(ID1);
   // Should have installed and started
   BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
   BootstrapMonitor.checkAddonStarted(ID1, "2.0");
   notEqual(b1, null);
@@ -1067,18 +1062,17 @@ add_task(async function test_21() {
 
   await promiseStartupManager();
 });
 
 // Check that an upgrade from the filesystem is detected and applied correctly
 add_task(async function test_22() {
   await promiseShutdownManager();
 
-  let file = manuallyInstall(XPIS.test_bootstrap1_1, profileDir,
-                             ID1);
+  let file = await manuallyInstall(XPIS.test_bootstrap1_1, profileDir, ID1);
   if (file.isDirectory())
     file.append("install.rdf");
 
   // Make it look old so changes are detected
   setExtensionModifiedTime(file, file.lastModifiedTime - 5000);
 
   await promiseStartupManager();
 
@@ -1093,18 +1087,17 @@ add_task(async function test_22() {
 
   await promiseShutdownManager();
 
   equal(getShutdownReason(), APP_SHUTDOWN);
   equal(getShutdownNewVersion(), undefined);
 
   manuallyUninstall(profileDir, ID1);
   BootstrapMonitor.clear(ID1);
-  manuallyInstall(XPIS.test_bootstrap1_2, profileDir,
-                  ID1);
+  await manuallyInstall(XPIS.test_bootstrap1_2, profileDir, ID1);
 
   await promiseStartupManager();
 
   let b1_2 = await AddonManager.getAddonByID(ID1);
   // Should have installed and started
   BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
   BootstrapMonitor.checkAddonStarted(ID1, "2.0");
   notEqual(b1_2, null);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js
@@ -10,27 +10,27 @@ createAppInfo("xpcshell@tests.mozilla.or
 const EXPECTED_GLOBALS = [
   ["Worker", "function"],
   ["ChromeWorker", "function"],
   ["console", "object"]
 ];
 
 async function run_test() {
   do_test_pending();
-  startupManager();
+  await promiseStartupManager();
   let sawGlobals = false;
 
   Services.obs.addObserver(function(subject) {
     subject.wrappedJSObject.expectedGlobals = EXPECTED_GLOBALS;
   }, "bootstrap-request-globals");
 
   Services.obs.addObserver(function({ wrappedJSObject: seenGlobals }) {
     for (let [name, ] of EXPECTED_GLOBALS)
       Assert.ok(seenGlobals.has(name));
 
     sawGlobals = true;
   }, "bootstrap-seen-globals");
 
   await promiseInstallAllFiles([do_get_addon("bootstrap_globals")]);
   Assert.ok(sawGlobals);
-  shutdownManager();
+  await promiseShutdownManager();
   do_test_finished();
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js
@@ -11,17 +11,17 @@ profileDir.append("extensions");
 
 const ID = "bootstrap1@tests.mozilla.org";
 
 add_task(async function() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   AddonTestUtils.manuallyInstall(do_get_addon("test_cache_certdb"), profileDir, ID);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Force a rescan of signatures
   const { XPIProvider } = ChromeUtils.import("resource://gre/modules/addons/XPIProvider.jsm", {});
   await XPIProvider.verifySignatures();
 
   let addon = await AddonManager.getAddonByID(ID);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
   Assert.ok(!addon.isActive);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js
@@ -306,31 +306,31 @@ var addon9 = {
     minVersion: "1",
     maxVersion: "1"
   }]
 };
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
-function run_test() {
+async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "2");
 
-  writeInstallRDFForExtension(addon1, profileDir);
-  writeInstallRDFForExtension(addon2, profileDir);
-  writeInstallRDFForExtension(addon3, profileDir);
-  writeInstallRDFForExtension(addon4, profileDir);
-  writeInstallRDFForExtension(addon5, profileDir);
-  writeInstallRDFForExtension(addon6, profileDir);
-  writeInstallRDFForExtension(addon7, profileDir);
-  writeInstallRDFForExtension(addon8, profileDir);
-  writeInstallRDFForExtension(addon9, profileDir);
+  await promiseWriteInstallRDFForExtension(addon1, profileDir);
+  await promiseWriteInstallRDFForExtension(addon2, profileDir);
+  await promiseWriteInstallRDFForExtension(addon3, profileDir);
+  await promiseWriteInstallRDFForExtension(addon4, profileDir);
+  await promiseWriteInstallRDFForExtension(addon5, profileDir);
+  await promiseWriteInstallRDFForExtension(addon6, profileDir);
+  await promiseWriteInstallRDFForExtension(addon7, profileDir);
+  await promiseWriteInstallRDFForExtension(addon8, profileDir);
+  await promiseWriteInstallRDFForExtension(addon9, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   AddonManagerInternal.backgroundUpdateCheck().then(run_test_1);
 }
 
 function end_test() {
   gServer.stop(do_test_finished);
 }
 
@@ -404,13 +404,13 @@ async function check_compat_status(aCall
   executeSoon(aCallback);
 }
 
 function run_test_1() {
   info("Run test 1");
   check_compat_status(run_test_2);
 }
 
-function run_test_2() {
+async function run_test_2() {
   info("Run test 2");
-  restartManager();
+  await promiseRestartManager();
   check_compat_status(end_test);
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_corruptfile.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_corruptfile.js
@@ -2,57 +2,50 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // Tests that attempting to install a corrupt XPI file doesn't break the universe
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
 
-  startupManager();
+  await promiseStartupManager();
 
   if (TEST_UNPACKED)
-    run_test_unpacked();
-  else
-    run_test_packed();
-}
+    return run_test_unpacked();
+  return run_test_packed();
+});
 
 // When installing packed we won't detect corruption in the XPI until we attempt
 // to load bootstrap.js so everything will look normal from the outside.
 async function run_test_packed() {
-  do_test_pending();
-
   prepare_test({
     "corrupt@tests.mozilla.org": [
       ["onInstalling", false],
       ["onInstalled", false]
     ]
   }, [
     "onNewInstall",
     "onInstallStarted",
     "onInstallEnded"
   ]);
 
   await promiseInstallAllFiles([do_get_file("data/corruptfile.xpi")]);
   ensure_test_completed();
 
   let addon = await AddonManager.getAddonByID("corrupt@tests.mozilla.org");
   Assert.notEqual(addon, null);
-
-  do_test_finished();
 }
 
 // When extracting the corruption will be detected and the add-on fails to
 // install
 async function run_test_unpacked() {
-  do_test_pending();
-
   prepare_test({
     "corrupt@tests.mozilla.org": [
       ["onInstalling", false],
       "onOperationCancelled"
     ]
   }, [
     "onNewInstall",
     "onInstallStarted",
@@ -69,11 +62,9 @@ async function run_test_unpacked() {
 
   // Check the staging directory isn't left over
   var stageDir = profileDir.clone();
   stageDir.append("staged");
   pathShouldntExist(stageDir);
 
   let addon = await AddonManager.getAddonByID("corrupt@tests.mozilla.org");
   Assert.equal(addon, null);
-
-  do_test_finished();
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js
@@ -22,18 +22,18 @@ const TEST_IGNORE_PREF = "delaytest.igno
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
 
 // Create and configure the HTTP server.
 var testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
 testserver.registerDirectory("/data/", do_get_file("data"));
 testserver.registerDirectory("/addons/", do_get_file("addons"));
 
-function createIgnoreAddon() {
-  writeInstallRDFToDir({
+async function createIgnoreAddon() {
+  await promiseWriteInstallRDFToDir({
     id: IGNORE_ID,
     version: "1.0",
     bootstrap: true,
     unpack: true,
     updateURL: `http://example.com/data/test_delay_updates_ignore_legacy.json`,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
@@ -43,18 +43,18 @@ function createIgnoreAddon() {
   }, profileDir, IGNORE_ID, "bootstrap.js");
 
   let unpacked_addon = profileDir.clone();
   unpacked_addon.append(IGNORE_ID);
   do_get_file("data/test_delay_update_ignore/bootstrap.js")
     .copyTo(unpacked_addon, "bootstrap.js");
 }
 
-function createCompleteAddon() {
-  writeInstallRDFToDir({
+async function createCompleteAddon() {
+  await promiseWriteInstallRDFToDir({
     id: COMPLETE_ID,
     version: "1.0",
     bootstrap: true,
     unpack: true,
     updateURL: `http://example.com/data/test_delay_updates_complete_legacy.json`,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
@@ -64,18 +64,18 @@ function createCompleteAddon() {
   }, profileDir, COMPLETE_ID, "bootstrap.js");
 
   let unpacked_addon = profileDir.clone();
   unpacked_addon.append(COMPLETE_ID);
   do_get_file("data/test_delay_update_complete/bootstrap.js")
     .copyTo(unpacked_addon, "bootstrap.js");
 }
 
-function createDeferAddon() {
-  writeInstallRDFToDir({
+async function createDeferAddon() {
+  await promiseWriteInstallRDFToDir({
     id: DEFER_ID,
     version: "1.0",
     bootstrap: true,
     unpack: true,
     updateURL: `http://example.com/data/test_delay_updates_defer_legacy.json`,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
@@ -90,17 +90,17 @@ function createDeferAddon() {
     .copyTo(unpacked_addon, "bootstrap.js");
 }
 
 // add-on registers upgrade listener, and ignores update.
 add_task(async function() {
 
   await createIgnoreAddon();
 
-  startupManager();
+  await promiseStartupManager();
 
   let addon = await promiseAddonByID(IGNORE_ID);
   Assert.notEqual(addon, null);
   Assert.equal(addon.version, "1.0");
   Assert.equal(addon.name, "Test Delay Update Ignore");
   Assert.ok(addon.isCompatible);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
@@ -131,25 +131,25 @@ add_task(async function() {
   Assert.notEqual(addon_upgraded, null);
   Assert.equal(addon_upgraded.version, "2.0");
   Assert.equal(addon_upgraded.name, "Test Delay Update Ignore");
   Assert.ok(addon_upgraded.isCompatible);
   Assert.ok(!addon_upgraded.appDisabled);
   Assert.ok(addon_upgraded.isActive);
   Assert.equal(addon_upgraded.type, "extension");
 
-  await shutdownManager();
+  await await promiseShutdownManager();
 });
 
 // add-on registers upgrade listener, and allows update.
 add_task(async function() {
 
   await createCompleteAddon();
 
-  startupManager();
+  await promiseStartupManager();
 
   let addon = await promiseAddonByID(COMPLETE_ID);
   Assert.notEqual(addon, null);
   Assert.equal(addon.version, "1.0");
   Assert.equal(addon.name, "Test Delay Update Complete");
   Assert.ok(addon.isCompatible);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
@@ -187,25 +187,25 @@ add_task(async function() {
   Assert.notEqual(addon_upgraded, null);
   Assert.equal(addon_upgraded.version, "2.0");
   Assert.equal(addon_upgraded.name, "Test Delay Update Complete");
   Assert.ok(addon_upgraded.isCompatible);
   Assert.ok(!addon_upgraded.appDisabled);
   Assert.ok(addon_upgraded.isActive);
   Assert.equal(addon_upgraded.type, "extension");
 
-  await shutdownManager();
+  await await promiseShutdownManager();
 });
 
 // add-on registers upgrade listener, initially defers update then allows upgrade
 add_task(async function() {
 
   await createDeferAddon();
 
-  startupManager();
+  await promiseStartupManager();
 
   let addon = await promiseAddonByID(DEFER_ID);
   Assert.notEqual(addon, null);
   Assert.equal(addon.version, "1.0");
   Assert.equal(addon.name, "Test Delay Update Defer");
   Assert.ok(addon.isCompatible);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
@@ -246,10 +246,10 @@ add_task(async function() {
   Assert.notEqual(addon_upgraded, null);
   Assert.equal(addon_upgraded.version, "2.0");
   Assert.equal(addon_upgraded.name, "Test Delay Update Defer");
   Assert.ok(addon_upgraded.isCompatible);
   Assert.ok(!addon_upgraded.appDisabled);
   Assert.ok(addon_upgraded.isActive);
   Assert.equal(addon_upgraded.type, "extension");
 
-  await shutdownManager();
+  await await promiseShutdownManager();
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js
@@ -34,17 +34,17 @@ const NOUPDATE_ID = "test_no_update_webe
 var testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
 testserver.registerDirectory("/data/", do_get_file("data"));
 testserver.registerDirectory("/addons/", do_get_file("addons"));
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "42", "42");
 
 // add-on registers upgrade listener, and ignores update.
 add_task(async function delay_updates_ignore() {
-  startupManager();
+  await promiseStartupManager();
 
   let extension = ExtensionTestUtils.loadExtension({
     useAddonManager: "permanent",
     manifest: {
       "version": "1.0",
       "applications": {
         "gecko": {
           "id": IGNORE_ID,
@@ -113,17 +113,17 @@ add_task(async function delay_updates_ig
   Assert.equal(addon_upgraded.type, "extension");
 
   await extension.unload();
   await promiseShutdownManager();
 });
 
 // add-on registers upgrade listener, and allows update.
 add_task(async function delay_updates_complete() {
-  startupManager();
+  await promiseStartupManager();
 
   let extension = ExtensionTestUtils.loadExtension({
     useAddonManager: "permanent",
     manifest: {
       "version": "1.0",
       "applications": {
         "gecko": {
           "id": COMPLETE_ID,
@@ -176,17 +176,17 @@ add_task(async function delay_updates_co
   }
 
   await extension.unload();
   await promiseShutdownManager();
 });
 
 // add-on registers upgrade listener, initially defers update then allows upgrade
 add_task(async function delay_updates_defer() {
-  startupManager();
+  await promiseStartupManager();
 
   let extension = ExtensionTestUtils.loadExtension({
     useAddonManager: "permanent",
     manifest: {
       "version": "1.0",
       "applications": {
         "gecko": {
           "id": DEFER_ID,
@@ -272,17 +272,17 @@ add_task(async function delay_updates_de
   Assert.equal(addon_allowed.type, "extension");
 
   await extension.unload();
   await promiseShutdownManager();
 });
 
 // browser.runtime.reload() without a pending upgrade should just reload.
 add_task(async function runtime_reload() {
-  startupManager();
+  await promiseStartupManager();
 
   let extension = ExtensionTestUtils.loadExtension({
     useAddonManager: "permanent",
     manifest: {
       "version": "1.0",
       "applications": {
         "gecko": {
           "id": NOUPDATE_ID,
--- a/toolkit/mozapps/extensions/test/xpcshell/test_distribution.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_distribution.js
@@ -56,40 +56,40 @@ var addon1_3 = {
 function getActiveVersion() {
   return Services.prefs.getIntPref("bootstraptest.active_version");
 }
 
 function getInstalledVersion() {
   return Services.prefs.getIntPref("bootstraptest.installed_version");
 }
 
-function setOldModificationTime() {
+async function setOldModificationTime() {
   // Make sure the installed extension has an old modification time so any
   // changes will be detected
-  shutdownManager();
+  await promiseShutdownManager();
   let extension = gProfD.clone();
   extension.append("extensions");
   extension.append("addon1@tests.mozilla.org.xpi");
   setExtensionModifiedTime(extension, Date.now() - MAKE_FILE_OLD_DIFFERENCE);
-  startupManager();
+  await promiseStartupManager();
 }
 
 function run_test() {
   do_test_pending();
 
   run_test_1();
 }
 
 // Tests that on the first startup the add-on gets installed, with now as the
 // profile modifiedTime.
 async function run_test_1() {
-  let extension = writeInstallRDFForExtension(addon1_1, distroDir);
+  let extension = await promiseWriteInstallRDFForExtension(addon1_1, distroDir);
   setExtensionModifiedTime(extension, Date.now() - MAKE_FILE_OLD_DIFFERENCE);
 
-  startupManager();
+  await promiseStartupManager();
 
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(a1, null);
   Assert.equal(a1.version, "1.0");
   Assert.ok(a1.isActive);
   Assert.equal(a1.scope, AddonManager.SCOPE_PROFILE);
   Assert.ok(!a1.foreignInstall);
 
@@ -103,134 +103,134 @@ async function run_test_1() {
   Assert.ok(Math.abs(difference) < MAX_TIME_DIFFERENCE);
 
   executeSoon(run_test_2);
 }
 
 // Tests that starting with a newer version in the distribution dir doesn't
 // install it yet
 async function run_test_2() {
-  setOldModificationTime();
+  await setOldModificationTime();
 
-  writeInstallRDFForExtension(addon1_2, distroDir);
+  await promiseWriteInstallRDFForExtension(addon1_2, distroDir);
 
-  restartManager();
+  await promiseRestartManager();
 
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(a1, null);
   Assert.equal(a1.version, "1.0");
   Assert.ok(a1.isActive);
   Assert.equal(a1.scope, AddonManager.SCOPE_PROFILE);
 
   executeSoon(run_test_3);
 }
 
 // Test that an app upgrade installs the newer version
 async function run_test_3() {
-  restartManager("2");
+  await promiseRestartManager("2");
 
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(a1, null);
   Assert.equal(a1.version, "2.0");
   Assert.ok(a1.isActive);
   Assert.equal(a1.scope, AddonManager.SCOPE_PROFILE);
   Assert.ok(!a1.foreignInstall);
 
   executeSoon(run_test_4);
 }
 
 // Test that an app upgrade doesn't downgrade the extension
 async function run_test_4() {
-  setOldModificationTime();
+  await setOldModificationTime();
 
-  writeInstallRDFForExtension(addon1_1, distroDir);
+  await promiseWriteInstallRDFForExtension(addon1_1, distroDir);
 
-  restartManager("3");
+  await promiseRestartManager("3");
 
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(a1, null);
   Assert.equal(a1.version, "2.0");
   Assert.ok(a1.isActive);
   Assert.equal(a1.scope, AddonManager.SCOPE_PROFILE);
 
   executeSoon(run_test_5);
 }
 
 // Tests that after uninstalling a restart doesn't re-install the extension
 async function run_test_5() {
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   a1.uninstall();
 
-  restartManager();
+  await promiseRestartManager();
 
   let a1_2 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.equal(a1_2, null);
 
   executeSoon(run_test_6);
 }
 
 // Tests that upgrading the application still doesn't re-install the uninstalled
 // extension
 async function run_test_6() {
-  restartManager("4");
+  await promiseRestartManager("4");
 
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.equal(a1, null);
 
   executeSoon(run_test_7);
 }
 
 // Tests that a pending install of a newer version of a distributed add-on
 // at app change still gets applied
 async function run_test_7() {
   Services.prefs.clearUserPref("extensions.installedDistroAddon.addon1@tests.mozilla.org");
 
   await promiseInstallAllFiles([do_get_addon("test_distribution1_2")]);
-  restartManager(2);
+  await promiseRestartManager(2);
 
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(a1, null);
   Assert.equal(a1.version, "2.0");
   Assert.ok(a1.isActive);
   Assert.equal(a1.scope, AddonManager.SCOPE_PROFILE);
 
   a1.uninstall();
   executeSoon(run_test_8);
 }
 
 // Tests that a pending install of a older version of a distributed add-on
 // at app change gets replaced by the distributed version
 async function run_test_8() {
-  restartManager();
+  await promiseRestartManager();
 
-  writeInstallRDFForExtension(addon1_3, distroDir);
+  await promiseWriteInstallRDFForExtension(addon1_3, distroDir);
 
   await promiseInstallAllFiles([do_get_addon("test_distribution1_2")]);
-  restartManager(3);
+  await promiseRestartManager(3);
 
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(a1, null);
   Assert.equal(a1.version, "3.0");
   Assert.ok(a1.isActive);
   Assert.equal(a1.scope, AddonManager.SCOPE_PROFILE);
 
   a1.uninstall();
   executeSoon(run_test_9);
 }
 
 // Tests that bootstrapped add-ons distributed start up correctly, also that
 // add-ons with multiple directories get copied fully
 async function run_test_9() {
-  restartManager();
+  await promiseRestartManager();
 
   // Copy the test add-on to the distro dir
   let addon = do_get_file("data/test_distribution2_2");
   addon.copyTo(distroDir, "addon2@tests.mozilla.org");
 
-  restartManager("5");
+  await promiseRestartManager("5");
 
   let a2 = await AddonManager.getAddonByID("addon2@tests.mozilla.org");
   Assert.notEqual(a2, null);
   Assert.ok(a2.isActive);
 
   Assert.equal(getInstalledVersion(), 2);
   Assert.equal(getActiveVersion(), 2);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js
@@ -64,22 +64,22 @@ var PLUGINS = [{
   enabledState: Ci.nsIPluginTag.STATE_ENABLED,
   filename: "/home/mozilla/.plugins/dupplugin5.so"
 }].map(opts => new MockPlugin(opts));
 
 mockPluginHost(PLUGINS);
 
 var gPluginIDs = [null, null, null, null, null];
 
-function run_test() {
+async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   Services.prefs.setBoolPref("media.gmp-provider.enabled", false);
 
-  startupManager();
+  await promiseStartupManager();
 
   run_test_1();
 }
 
 function found_plugin(aNum, aId) {
   if (gPluginIDs[aNum])
     do_throw("Found duplicate of plugin " + aNum);
   gPluginIDs[aNum] = aId;
@@ -122,26 +122,26 @@ async function run_test_2() {
   Assert.ok(PLUGINS[0].disabled);
   Assert.ok(PLUGINS[1].disabled);
 
   executeSoon(run_test_3);
 }
 
 // Test that IDs persist across restart
 async function run_test_3() {
-  restartManager();
+  await promiseRestartManager();
 
   let p = await AddonManager.getAddonByID(gPluginIDs[0]);
   Assert.notEqual(p, null);
   Assert.equal(p.name, "Duplicate Plugin 1");
   Assert.equal(p.description, "A duplicate plugin");
 
   // Reorder the plugins and restart again
   [PLUGINS[0], PLUGINS[1]] = [PLUGINS[1], PLUGINS[0]];
-  restartManager();
+  await promiseRestartManager();
 
   let p_2 = await AddonManager.getAddonByID(gPluginIDs[0]);
   Assert.notEqual(p_2, null);
   Assert.equal(p_2.name, "Duplicate Plugin 1");
   Assert.equal(p_2.description, "A duplicate plugin");
 
   executeSoon(do_test_finished);
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_error.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_error.js
@@ -4,22 +4,22 @@
 
 // Tests that various error conditions are handled correctly
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
-function run_test() {
+async function run_test() {
+  do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
-  startupManager();
+  await promiseStartupManager();
 
-  do_test_pending();
   run_test_1();
 }
 
 // Checks that a local file validates ok
 async function run_test_1() {
   let install = await AddonManager.getInstallForFile(do_get_file("data/unsigned.xpi"));
   Assert.notEqual(install, null);
   Assert.equal(install.state, AddonManager.STATE_DOWNLOADED);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js
@@ -1,13 +1,13 @@
 "use strict";
 
 add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "48", "48");
-  startupManager();
+  await promiseStartupManager();
 });
 
 /* eslint-disable no-undef */
 // Shared background function for getSelf tests
 function backgroundGetSelf() {
   browser.management.getSelf().then(extInfo => {
     let url = browser.extension.getURL("*");
     extInfo.hostPermissions = extInfo.hostPermissions.filter(i => i != url);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
@@ -204,27 +204,27 @@ add_task(async function test_bad_pointer
 
   let pointer = profileDir.clone();
   pointer.append("addon2@tests.mozilla.org");
   ok(!pointer.exists());
 });
 
 // Tests that changing the ID of an existing add-on doesn't clobber the sources
 add_task(async function test_bad_pointer_id() {
-  var dest = writeInstallRDFForExtension(addon1, sourceDir);
+  var dest = await promiseWriteInstallRDFForExtension(addon1, sourceDir);
   // Make sure the modification time changes enough to be detected.
   setExtensionModifiedTime(dest, dest.lastModifiedTime - 5000);
   await promiseWritePointer(addon1.id);
   await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID(addon1.id);
   notEqual(addon, null);
   equal(addon.version, "1.0");
 
-  writeInstallRDFForExtension(addon2, sourceDir, addon1.id);
+  await promiseWriteInstallRDFForExtension(addon2, sourceDir, addon1.id);
 
   await promiseRestartManager();
 
   let [a1, a2] = await AddonManager.getAddonsByIDs(
     ["addon1@tests.mozilla.org", "addon2@tests.mozilla.org"]);
 
   equal(a1, null);
   equal(a2, null);
@@ -235,17 +235,17 @@ add_task(async function test_bad_pointer
 
   let pointer = profileDir.clone();
   pointer.append(addon1.id);
   ok(!pointer.exists());
 });
 
 // Removing the pointer file should uninstall the add-on
 add_task(async function test_remove_pointer() {
-  var dest = writeInstallRDFForExtension(addon1, sourceDir);
+  var dest = await promiseWriteInstallRDFForExtension(addon1, sourceDir);
   // Make sure the modification time changes enough to be detected in run_test_8.
   setExtensionModifiedTime(dest, dest.lastModifiedTime - 5000);
   await promiseWritePointer(addon1.id);
 
   await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID(addon1.id);
   notEqual(addon, null);
@@ -269,17 +269,17 @@ add_task(async function test_replace_poi
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   notEqual(addon, null);
   equal(addon.version, "1.0");
 
   let pointer = profileDir.clone();
   pointer.append(addon1.id);
   pointer.remove(false);
 
-  writeInstallRDFForExtension(addon1_2, profileDir);
+  await promiseWriteInstallRDFForExtension(addon1_2, profileDir);
 
   await promiseRestartManager();
 
   addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   notEqual(addon, null);
   equal(addon.version, "2.0");
 
   addon.uninstall();
@@ -290,31 +290,31 @@ add_task(async function test_change_poin
   await promiseRestartManager();
   await promiseWritePointer(addon1.id);
   await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   notEqual(addon, null);
   equal(addon.version, "1.0");
 
-  writeInstallRDFForExtension(addon1_2, sourceDir);
+  await promiseWriteInstallRDFForExtension(addon1_2, sourceDir);
 
   await promiseRestartManager();
 
   addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   notEqual(addon, null);
   equal(addon.version, "2.0");
 
   addon.uninstall();
 });
 
 // Removing the add-on the pointer file points at should uninstall the add-on
 add_task(async function test_remove_pointer_target() {
   await promiseRestartManager();
-  var dest = writeInstallRDFForExtension(addon1, sourceDir);
+  var dest = await promiseWriteInstallRDFForExtension(addon1, sourceDir);
   await promiseWritePointer(addon1.id);
   await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID(addon1.id);
   notEqual(addon, null);
   equal(addon.version, "1.0");
 
   dest.remove(true);
@@ -326,17 +326,17 @@ add_task(async function test_remove_poin
 
   let pointer = profileDir.clone();
   pointer.append(addon1.id);
   ok(!pointer.exists());
 });
 
 // Tests that installing a new add-on by pointer with a relative path works
 add_task(async function test_new_relative_pointer() {
-  writeInstallRDFForExtension(addon1, sourceDir);
+  await promiseWriteInstallRDFForExtension(addon1, sourceDir);
   await promiseWriteRelativePointer(addon1.id);
   await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID(addon1.id);
   equal(addon.version, "1.0");
 
   let file = addon.getResourceURI().QueryInterface(Ci.nsIFileURL).file;
   equal(file.parent.path, sourceDir.path);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_general.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_general.js
@@ -8,45 +8,45 @@
 // We have to look up how many add-ons are present since there will be plugins
 // etc. detected
 var gCount;
 
 async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
-  startupManager();
+  await promiseStartupManager();
   let list = await AddonManager.getAddonsByTypes(null);
   gCount = list.length;
 
   executeSoon(run_test_1);
 }
 
 async function run_test_1() {
-  restartManager();
+  await promiseRestartManager();
 
   let addons = await AddonManager.getAddonsByTypes(null);
   Assert.equal(gCount, addons.length);
 
   let pendingAddons = await AddonManager.getAddonsWithOperationsByTypes(null);
   Assert.equal(0, pendingAddons.length);
 
   executeSoon(run_test_2);
 }
 
 async function run_test_2() {
-  shutdownManager();
+  await promiseShutdownManager();
 
-  startupManager();
+  await promiseStartupManager();
 
   let addons = await AddonManager.getAddonsByTypes(null);
   Assert.equal(gCount, addons.length);
 
   executeSoon(run_test_3);
 }
 
 async function run_test_3() {
-  restartManager();
+  await promiseRestartManager();
 
   let addons = await AddonManager.getAddonsByTypes(null);
   Assert.equal(gCount, addons.length);
   do_test_finished();
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_getresource.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_getresource.js
@@ -8,17 +8,17 @@ const ADDON_SIZE = 672 + 15 + 26;
 // This verifies the functionality of getResourceURI
 // There are two cases - with a filename it returns an nsIFileURL to the filename
 // and with no parameters, it returns an nsIFileURL to the root of the addon
 
 async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
 
-  startupManager();
+  await promiseStartupManager();
 
   let aInstall = await AddonManager.getInstallForFile(do_get_addon("test_getresource"));
   Assert.ok(aInstall.addon.hasResource("install.rdf"));
   Assert.equal(aInstall.addon.getResourceURI().spec, aInstall.sourceURI.spec);
 
   Assert.ok(aInstall.addon.hasResource("icon.png"));
   Assert.equal(aInstall.addon.getResourceURI("icon.png").spec,
                "jar:" + aInstall.sourceURI.spec + "!/icon.png");
@@ -29,17 +29,17 @@ async function run_test() {
   Assert.equal(aInstall.addon.getResourceURI("subdir/subfile.txt").spec,
                "jar:" + aInstall.sourceURI.spec + "!/subdir/subfile.txt");
 
   Assert.ok(!aInstall.addon.hasResource("subdir/missing.txt"));
 
   Assert.equal(aInstall.addon.size, ADDON_SIZE);
 
   await promiseCompleteAllInstalls([aInstall]);
-  restartManager();
+  await promiseRestartManager();
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(a1, null);
 
   let addonDir = gProfD.clone();
   addonDir.append("extensions");
   let rootUri = do_get_addon_root_uri(addonDir, "addon1@tests.mozilla.org");
 
   let uri = a1.getResourceURI("/");
@@ -74,15 +74,15 @@ async function run_test() {
   } catch (e) {
     Assert.ok(false);
   }
 
   let aInstall_2 = await AddonManager.getInstallForFile(do_get_addon("test_getresource"));
   Assert.ok(!a1.hasResource("icon.png"));
   Assert.ok(aInstall_2.addon.hasResource("icon.png"));
 
-  restartManager();
+  await promiseRestartManager();
 
   let newa1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.equal(newa1, null);
 
   executeSoon(do_test_finished);
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -51,20 +51,20 @@ function run_test() {
       break;
     case "Android":
       gfxInfo.spoofVendorID("abcd");
       gfxInfo.spoofDeviceID("aabb");
       gfxInfo.spoofDriverVersion("5");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -50,20 +50,20 @@ function run_test() {
       return;
     case "Android":
       gfxInfo.spoofVendorID("abcd");
       gfxInfo.spoofDeviceID("wxyz");
       gfxInfo.spoofDriverVersion("6");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -50,20 +50,20 @@ function run_test() {
       return;
     case "Android":
       gfxInfo.spoofVendorID("dcdc");
       gfxInfo.spoofDeviceID("uiop");
       gfxInfo.spoofDriverVersion("6");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "15.0", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
     // Make sure unrelated features aren't affected
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
@@ -16,17 +16,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -51,20 +51,20 @@ function run_test() {
       return;
     case "Android":
       gfxInfo.spoofVendorID("dcdc");
       gfxInfo.spoofDeviceID("uiop");
       gfxInfo.spoofDriverVersion("4");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
     // Make sure unrelated features aren't affected
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -50,20 +50,20 @@ function run_test() {
       return;
     case "Android":
       gfxInfo.spoofVendorID("dcdc");
       gfxInfo.spoofDeviceID("uiop");
       gfxInfo.spoofDriverVersion("5");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
 
     // Make sure unrelated features aren't affected
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -50,20 +50,20 @@ function run_test() {
       return;
     case "Android":
       gfxInfo.spoofVendorID("abab");
       gfxInfo.spoofDeviceID("ghjk");
       gfxInfo.spoofDriverVersion("6");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
     // Make sure unrelated features aren't affected
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -50,20 +50,20 @@ function run_test() {
       return;
     case "Android":
       gfxInfo.spoofVendorID("abab");
       gfxInfo.spoofDeviceID("ghjk");
       gfxInfo.spoofDriverVersion("7");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
 
     // Make sure unrelated features aren't affected
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -44,20 +44,20 @@ function run_test() {
       break;
     case "Darwin":
       gfxInfo.spoofOSVersion(0x1090);
       break;
     case "Android":
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var driverVersion = gfxInfo.adapterDriverVersion;
     if (driverVersion) {
       var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
       Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DEVICE);
 
       // Make sure unrelated features aren't affected
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -51,20 +51,20 @@ function run_test() {
       break;
     case "Android":
       gfxInfo.spoofVendorID("abcd");
       gfxInfo.spoofDeviceID("asdf");
       gfxInfo.spoofDriverVersion("5");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
 
     // Make sure unrelated features aren't affected
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -51,20 +51,20 @@ function run_test() {
       break;
     case "Android":
       // On Android, the driver version is used as the OS version (because
       // there's so many of them).
       do_test_finished();
       return;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
@@ -14,17 +14,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -51,20 +51,20 @@ function run_test() {
       break;
     case "Android":
       // On Android, the driver version is used as the OS version (because
       // there's so many of them).
       do_test_finished();
       return;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     if (Services.appinfo.OS == "WINNT") {
       var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
       Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
     } else if (Services.appinfo.OS == "Darwin") {
       status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
       Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -51,20 +51,20 @@ function run_test() {
       break;
     case "Android":
       // On Android, the driver version is used as the OS version (because
       // there's so many of them).
       do_test_finished();
       return;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     if (Services.appinfo.OS == "WINNT") {
       var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
       Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
     } else if (Services.appinfo.OS == "Darwin") {
       status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
       Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -52,20 +52,20 @@ function run_test() {
       break;
     case "Android":
       // On Android, the driver version is used as the OS version (because
       // there's so many of them).
       do_test_finished();
       return;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     if (Services.appinfo.OS == "WINNT") {
       var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
       Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
     } else if (Services.appinfo.OS == "Darwin") {
       status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
       Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
@@ -15,17 +15,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -51,20 +51,20 @@ function run_test() {
       break;
     case "Android":
       gfxInfo.spoofVendorID("dcba");
       gfxInfo.spoofDeviceID("asdf");
       gfxInfo.spoofDriverVersion("5");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
@@ -14,17 +14,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
 
   // We can't do anything if we can't spoof the stuff we need.
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
@@ -50,20 +50,20 @@ function run_test() {
       break;
     case "Android":
       gfxInfo.spoofVendorID("abcd");
       gfxInfo.spoofDeviceID("asdf");
       gfxInfo.spoofDriverVersion("5");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "15.0", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function checkBlacklist() {
     var failureId = {};
     var status;
 
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D, failureId);
     Assert.equal(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
     Assert.equal(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_g1");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
@@ -14,17 +14,17 @@ function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
 // Performs the initial setup
-function run_test() {
+async function run_test() {
   try {
     var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
   } catch (e) {
     do_test_finished();
     return;
   }
 
   // We can't do anything if we can't spoof the stuff we need.
@@ -55,20 +55,20 @@ function run_test() {
       break;
     case "Android":
       gfxInfo.spoofVendorID("abcd");
       gfxInfo.spoofDeviceID("asdf");
       gfxInfo.spoofDriverVersion("5");
       break;
   }
 
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  do_test_pending();
+  await promiseStartupManager();
 
   function blacklistAdded(aSubject, aTopic, aData) {
     // If we wait until after we go through the event loop, gfxInfo is sure to
     // have processed the gfxItems event.
     executeSoon(ensureBlacklistSet);
   }
   function ensureBlacklistSet() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
@@ -48,32 +48,30 @@ MockGMPInstallManager.prototype = {
 
   installAddon: addon => {
     gInstalledAddonId = addon.id;
     return Promise.resolve();
   },
 };
 
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-  startupManager();
+  await promiseStartupManager();
 
   gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP, true);
   gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL, 0);
   gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
   for (let addon of gMockAddons.values()) {
     gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id),
                        true);
     gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, addon.id),
                        true);
   }
-
-  run_next_test();
-}
+});
 
 add_task(async function init() {
   await GMPScope.GMPProvider.shutdown();
   GMPScope.GMPProvider.startup();
 });
 
 add_task(async function test_notInstalled() {
   for (let addon of gMockAddons.values()) {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js
@@ -7,20 +7,20 @@ ChromeUtils.import("resource://testing-c
 var gServer = new HttpServer();
 gServer.start(-1);
 gPort = gServer.identity.primaryPort;
 
 var addon_url = "http://localhost:" + gPort + "/test.xpi";
 var icon32_url = "http://localhost:" + gPort + "/icon.png";
 var icon64_url = "http://localhost:" + gPort + "/icon64.png";
 
-function run_test() {
+async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-  startupManager();
+  await promiseStartupManager();
 
   test_1();
 }
 
 async function test_1() {
   let aInstall = await AddonManager.getInstallForURL(addon_url, "application/x-xpinstall", null, null, null, null, null);
   Assert.equal(aInstall.iconURL, null);
   Assert.notEqual(aInstall.icons, null);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_isReady.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_isReady.js
@@ -11,17 +11,17 @@ add_task(async function() {
     },
     onShutdown() {
       gotShutdownEvent = true;
     },
   };
   AddonManager.addManagerListener(listener);
 
   info("Starting manager...");
-  startupManager();
+  await promiseStartupManager();
   equal(AddonManager.isReady, true, "isReady should be true after startup");
   equal(gotStartupEvent, true, "Should have seen onStartup event after startup");
   equal(gotShutdownEvent, false, "Should not have seen onShutdown event before shutdown");
 
   gotStartupEvent = false;
   gotShutdownEvent = false;
 
   info("Shutting down manager...");
@@ -33,13 +33,13 @@ add_task(async function() {
   equal(gotStartupEvent, false, "Should not have seen onStartup event after shutdown");
   equal(gotShutdownEvent, true, "Should have seen onShutdown event after shutdown");
 
   AddonManager.addManagerListener(listener);
   gotStartupEvent = false;
   gotShutdownEvent = false;
 
   info("Starting manager again...");
-  startupManager();
+  await promiseStartupManager();
   equal(AddonManager.isReady, true, "isReady should be true after repeat startup");
   equal(gotStartupEvent, true, "Should have seen onStartup event after repeat startup");
   equal(gotShutdownEvent, false, "Should not have seen onShutdown event before shutdown, following repeat startup");
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
@@ -70,17 +70,17 @@ function checkUpdates(aData) {
     });
   });
 }
 
 
 add_task(async function test_default_values() {
   // Checks that the appropriate defaults are used for omitted values.
 
-  startupManager();
+  await promiseStartupManager();
 
   let updates = await checkUpdates({
     id: "updatecheck-defaults@tests.mozilla.org",
     version: "0.1",
     updates: [{
       version: "0.2"
     }]
   });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_locale.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_locale.js
@@ -1,20 +1,20 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-function run_test() {
+async function run_test() {
   do_test_pending();
 
   // Setup for test
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   Services.locale.setRequestedLocales(["fr-FR"]);
 
-  startupManager();
+  await promiseStartupManager();
 
   run_test_1();
 }
 
 // Tests that the localized properties are visible before installation
 async function run_test_1() {
   let install = await AddonManager.getInstallForFile(do_get_addon("test_locale"));
   Assert.equal(install.addon.name, "fr-FR Name");
@@ -29,103 +29,103 @@ async function run_test_1() {
     "onInstallStarted",
     "onInstallEnded",
   ], callback_soon(run_test_2));
   install.install();
 }
 
 // Tests that the localized properties are visible after installation
 async function run_test_2() {
-  restartManager();
+  await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(addon, null);
 
   Assert.equal(addon.name, "fr-FR Name");
   Assert.equal(addon.description, "fr-FR Description");
 
   addon.userDisabled = true;
   executeSoon(run_test_3);
 }
 
 // Test that the localized properties are still there when disabled.
 async function run_test_3() {
-  restartManager();
+  await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(addon, null);
   Assert.equal(addon.name, "fr-FR Name");
 
   executeSoon(run_test_4);
 }
 
 // Localised preference values should be ignored when the add-on is disabled
 async function run_test_4() {
   Services.prefs.setCharPref("extensions.addon1@tests.mozilla.org.name", "Name from prefs");
   Services.prefs.setCharPref("extensions.addon1@tests.mozilla.org.contributor.1", "Contributor 1");
   Services.prefs.setCharPref("extensions.addon1@tests.mozilla.org.contributor.2", "Contributor 2");
-  restartManager();
+  await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(addon, null);
   Assert.equal(addon.name, "fr-FR Name");
   let contributors = addon.contributors;
   Assert.equal(contributors.length, 3);
   Assert.equal(contributors[0], "Fr Contributor 1");
   Assert.equal(contributors[1], "Fr Contributor 2");
   Assert.equal(contributors[2], "Fr Contributor 3");
 
   executeSoon(run_test_5);
 }
 
 // Test that changing locale works
 async function run_test_5() {
   Services.locale.setRequestedLocales(["de-DE"]);
-  restartManager();
+  await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(addon, null);
 
   Assert.equal(addon.name, "de-DE Name");
   Assert.equal(addon.description, null);
 
   executeSoon(run_test_6);
 }
 
 // Test that missing locales use the fallbacks
 async function run_test_6() {
   Services.locale.setRequestedLocales(["nl-NL"]);
-  restartManager();
+  await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(addon, null);
 
   Assert.equal(addon.name, "Fallback Name");
   Assert.equal(addon.description, "Fallback Description");
 
   addon.userDisabled = false;
   executeSoon(run_test_7);
 }
 
 // Test that the prefs will override the fallbacks
 async function run_test_7() {
-  restartManager();
+  await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(addon, null);
 
   Assert.equal(addon.name, "Name from prefs");
 
   executeSoon(run_test_8);
 }
 
 // Test that the prefs will override localized values from the manifest
 async function run_test_8() {
   Services.locale.setRequestedLocales(["fr-FR"]);
-  restartManager();
+  await promiseRestartManager();
 
   let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(addon, null);
 
   Assert.equal(addon.name, "Name from prefs");
   let contributors = addon.contributors;
   Assert.equal(contributors.length, 2);
   Assert.equal(contributors[0], "Contributor 1");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_manifest_locales.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_manifest_locales.js
@@ -76,17 +76,17 @@ add_task(async function setup() {
 add_task(async function test_1() {
   let addon = await AddonManager.getAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.equal(addon.name, "fr Name");
   Assert.equal(addon.description, "fr Description");
 
   // Disable item
   addon.userDisabled = true;
-  restartManager();
+  await promiseRestartManager();
 
   let newAddon = await AddonManager.getAddonByID(ID);
   Assert.notEqual(newAddon, null);
   Assert.equal(newAddon.name, "fr Name");
 });
 
 add_task(async function test_2() {
   // Change locale. The more specific de-DE is the best match
--- a/toolkit/mozapps/extensions/test/xpcshell/test_moved_extension_metadata.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_moved_extension_metadata.js
@@ -72,20 +72,20 @@ const ADDONS = [
     `
   },
 ];
 
 const XPIS = ADDONS.map(addon => AddonTestUtils.createTempXPIFile(addon));
 
 add_task(async function test_1() {
   var time = Date.now();
-  var dir = writeInstallRDFForExtension(addon1, userDir);
+  var dir = await promiseWriteInstallRDFForExtension(addon1, userDir);
   setExtensionModifiedTime(dir, time);
 
-  manuallyInstall(XPIS[0], userDir, "addon2@tests.mozilla.org");
+  await manuallyInstall(XPIS[0], userDir, "addon2@tests.mozilla.org");
 
   await promiseStartupManager();
 
   let [a1, a2] = await AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                                     "addon2@tests.mozilla.org"]);
   Assert.notEqual(a1, null);
   Assert.ok(a1.appDisabled);
   Assert.ok(!a1.isActive);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js
@@ -30,17 +30,17 @@ function check_empty_state() {
 // After first run with no add-ons, we expect:
 // no extensions.json is created
 // no extensions.ini
 // database schema version preference is set
 // bootstrap add-ons preference is not found
 // add-on directory state preference is an empty array
 // no pending operations
 add_task(async function first_run() {
-  startupManager();
+  await promiseStartupManager();
   check_empty_state();
   await true;
 });
 
 // Now do something that causes a DB load, and re-check
 async function trigger_db_load() {
   let addonList = await AddonManager.getAddonsByTypes(["extension"]);
 
@@ -48,26 +48,26 @@ async function trigger_db_load() {
   check_empty_state();
 
   await true;
 }
 add_task(trigger_db_load);
 
 // Now restart the manager and check again
 add_task(async function restart_and_recheck() {
-  restartManager();
+  await promiseRestartManager();
   check_empty_state();
   await true;
 });
 
 // and reload the DB again
 add_task(trigger_db_load);
 
 // When we start up with no DB and an old database schema, we should update the
 // schema number but not create a database
-add_task(function upgrade_schema_version() {
-  shutdownManager();
+add_task(async function upgrade_schema_version() {
+  await promiseShutdownManager();
   Services.prefs.setIntPref("extensions.databaseSchema", 1);
 
-  startupManager();
+  await promiseStartupManager();
   Assert.equal(Services.prefs.getIntPref("extensions.databaseSchema"), DB_SCHEMA);
   check_empty_state();
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js
@@ -13,29 +13,29 @@ registerDirectory("XREAppFeat", distroDi
 const NORMAL_ID = "normal@tests.mozilla.org";
 const SYSTEM_ID = "system@tests.mozilla.org";
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
 
 // normal add-ons can be user disabled.
 add_task(async function() {
 
-  writeInstallRDFToXPI({
+  await promiseWriteInstallRDFToXPI({
     id: NORMAL_ID,
     version: "1.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test disabling hidden add-ons, non-hidden add-on case.",
   }, profileDir, NORMAL_ID);
 
-  startupManager();
+  await promiseStartupManager();
 
   let addon = await promiseAddonByID(NORMAL_ID);
   Assert.notEqual(addon, null);
   Assert.equal(addon.version, "1.0");
   Assert.equal(addon.name, "Test disabling hidden add-ons, non-hidden add-on case.");
   Assert.ok(addon.isCompatible);
   Assert.ok(!addon.appDisabled);
   Assert.ok(!addon.userDisabled);
@@ -51,37 +51,37 @@ add_task(async function() {
   Assert.ok(addon.isCompatible);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.userDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.type, "extension");
 
   addon.uninstall();
 
-  shutdownManager();
+  await promiseShutdownManager();
 });
 
 // system add-ons can never be user disabled.
 add_task(async function() {
 
-  writeInstallRDFToXPI({
+  await promiseWriteInstallRDFToXPI({
     id: SYSTEM_ID,
     version: "1.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test disabling hidden add-ons, hidden system add-on case.",
   }, distroDir, SYSTEM_ID);
 
   await overrideBuiltIns({ "system": [SYSTEM_ID] });
 
-  startupManager();
+  await promiseStartupManager();
 
   let addon = await promiseAddonByID(SYSTEM_ID);
   Assert.notEqual(addon, null);
   Assert.equal(addon.version, "1.0");
   Assert.equal(addon.name, "Test disabling hidden add-ons, hidden system add-on case.");
   Assert.ok(addon.isCompatible);
   Assert.ok(!addon.appDisabled);
   Assert.ok(!addon.userDisabled);
@@ -100,10 +100,10 @@ add_task(async function() {
   Assert.equal(addon.version, "1.0");
   Assert.equal(addon.name, "Test disabling hidden add-ons, hidden system add-on case.");
   Assert.ok(addon.isCompatible);
   Assert.ok(!addon.appDisabled);
   Assert.ok(!addon.userDisabled);
   Assert.ok(addon.isActive);
   Assert.equal(addon.type, "extension");
 
-  shutdownManager();
+  await promiseShutdownManager();
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_onPropertyChanged_appDisabled.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_onPropertyChanged_appDisabled.js
@@ -3,40 +3,40 @@
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
 async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "addon1@tests.mozilla.org",
     version: "1.0",
     name: "Test 1",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "0.1",
       maxVersion: "0.2"
     }]
   }, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   AddonManager.strictCompatibility = false;
 
   let aAddon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(aAddon, null);
   aAddon.userDisabled = true;
   executeSoon(run_test_1);
 }
 
 async function run_test_1() {
-  restartManager();
+  await promiseRestartManager();
   let aAddon = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(aAddon, null);
   Assert.ok(aAddon.userDisabled);
   Assert.ok(!aAddon.isActive);
   Assert.ok(!aAddon.appDisabled);
 
   prepare_test({
     "addon1@tests.mozilla.org": [
--- a/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
@@ -90,109 +90,109 @@ async function isBlocklisted(addon, appV
 }
 
 // On first run whataver is in the app dir should get copied to the profile
 add_test(async function test_copy() {
   clearBlocklists();
   copyToApp(OLD);
 
   incrementAppVersion();
-  startupManager();
+  await promiseStartupManager();
 
   reloadBlocklist();
   Assert.ok(!(await isBlocklisted(invalidAddon)));
   Assert.ok(!(await isBlocklisted(ancientAddon)));
   Assert.ok(await isBlocklisted(oldAddon));
   Assert.ok(!(await isBlocklisted(newAddon)));
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   run_next_test();
 });
 
 // An ancient blocklist should be ignored
 add_test(async function test_ancient() {
   clearBlocklists();
   copyToApp(ANCIENT);
   copyToProfile(OLD, OLD_TSTAMP);
 
   incrementAppVersion();
-  startupManager();
+  await promiseStartupManager();
 
   reloadBlocklist();
 
   Assert.ok(!(await isBlocklisted(invalidAddon)));
   Assert.ok(!(await isBlocklisted(ancientAddon)));
   Assert.ok(await isBlocklisted(oldAddon));
   Assert.ok(!(await isBlocklisted(newAddon)));
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   run_next_test();
 });
 
 // A new blocklist should override an old blocklist
 add_test(async function test_override() {
   clearBlocklists();
   copyToApp(NEW);
   copyToProfile(OLD, OLD_TSTAMP);
 
   incrementAppVersion();
-  startupManager();
+  await promiseStartupManager();
 
   reloadBlocklist();
 
   Assert.ok(!(await isBlocklisted(invalidAddon)));
   Assert.ok(!(await isBlocklisted(ancientAddon)));
   Assert.ok(!(await isBlocklisted(oldAddon)));
   Assert.ok(await isBlocklisted(newAddon));
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   run_next_test();
 });
 
 // An old blocklist shouldn't override a new blocklist
 add_test(async function test_retain() {
   clearBlocklists();
   copyToApp(OLD);
   copyToProfile(NEW, NEW_TSTAMP);
 
   incrementAppVersion();
-  startupManager();
+  await promiseStartupManager();
 
   reloadBlocklist();
 
   Assert.ok(!(await isBlocklisted(invalidAddon)));
   Assert.ok(!(await isBlocklisted(ancientAddon)));
   Assert.ok(!(await isBlocklisted(oldAddon)));
   Assert.ok(await isBlocklisted(newAddon));
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   run_next_test();
 });
 
 // A missing blocklist in the profile should still load an app-shipped blocklist
 add_test(async function test_missing() {
   clearBlocklists();
   copyToApp(OLD);
   copyToProfile(NEW, NEW_TSTAMP);
 
   incrementAppVersion();
-  startupManager();
-  shutdownManager();
+  await promiseStartupManager();
+  await promiseShutdownManager();
 
   let blocklist = FileUtils.getFile(KEY_PROFILEDIR, [FILE_BLOCKLIST]);
   blocklist.remove(true);
-  startupManager();
+  await promiseStartupManager();
 
   reloadBlocklist();
 
   Assert.ok(!(await isBlocklisted(invalidAddon)));
   Assert.ok(!(await isBlocklisted(ancientAddon)));
   Assert.ok(await isBlocklisted(oldAddon));
   Assert.ok(!(await isBlocklisted(newAddon)));
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   run_next_test();
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js
@@ -8,27 +8,27 @@ ChromeUtils.import("resource://gre/modul
 // be removed by the user.
 
 const XPI_MIMETYPE = "application/x-xpinstall";
 
 function newPrincipal(uri) {
   return Services.scriptSecurityManager.createCodebasePrincipal(NetUtil.newURI(uri), {});
 }
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
 
   Services.prefs.setCharPref("xpinstall.whitelist.add", "https://test1.com,https://test2.com");
   Services.prefs.setCharPref("xpinstall.whitelist.add.36", "https://test3.com,https://www.test4.com");
   Services.prefs.setCharPref("xpinstall.whitelist.add.test5", "https://test5.com");
 
   Services.perms.add(NetUtil.newURI("https://www.test9.com"), "install",
                      Ci.nsIPermissionManager.ALLOW_ACTION);
 
-  startupManager();
+  await promiseStartupManager();
 
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("http://test1.com")));
   Assert.ok(AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                           newPrincipal("https://test1.com")));
   Assert.ok(AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                           newPrincipal("https://www.test2.com")));
   Assert.ok(AddonManager.isInstallAllowed(XPI_MIMETYPE,
@@ -66,21 +66,21 @@ function run_test() {
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("https://test3.com")));
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("https://www.test4.com")));
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("https://www.test5.com")));
 
   // Upgrade the application and verify that the permissions are still not there
-  restartManager("2");
+  await promiseRestartManager("2");
 
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("https://test1.com")));
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("https://www.test2.com")));
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("https://test3.com")));
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("https://www.test4.com")));
   Assert.ok(!AddonManager.isInstallAllowed(XPI_MIMETYPE,
                                            newPrincipal("https://www.test5.com")));
-}
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js
@@ -23,31 +23,31 @@ function do_check_permission_prefs(prefe
   }
 }
 
 function clear_imported_preferences_cache() {
   let scope = ChromeUtils.import("resource://gre/modules/PermissionsUtils.jsm", {});
   scope.gImportedPrefBranches.clear();
 }
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
 
   // Create own preferences to test
   Services.prefs.setCharPref("xpinstall.whitelist.add.EMPTY", "");
   Services.prefs.setCharPref("xpinstall.whitelist.add.TEST", "http://whitelist.example.com");
   Services.prefs.setCharPref("xpinstall.blacklist.add.EMPTY", "");
   Services.prefs.setCharPref("xpinstall.blacklist.add.TEST", "http://blacklist.example.com");
 
   // Get list of preferences to check
   var whitelistPreferences = Services.prefs.getChildList(PREF_XPI_WHITELIST_PERMISSIONS, {});
   var blacklistPreferences = Services.prefs.getChildList(PREF_XPI_BLACKLIST_PERMISSIONS, {});
   var preferences = whitelistPreferences.concat(blacklistPreferences);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Permissions are imported lazily - act as thought we're checking an install,
   // to trigger on-deman importing of the permissions.
   AddonManager.isInstallAllowed("application/x-xpinstall", newPrincipal("http://example.com/file.xpi"));
   do_check_permission_prefs(preferences);
 
 
   // Import can also be triggered by an observer notification by any other area
@@ -65,9 +65,9 @@ function run_test() {
   Services.obs.notifyObservers(null, "flush-pending-permissions");
   do_check_permission_prefs(preferences);
 
   // And a request to flush some other permissions sholdn't flush install permissions
   clear_imported_preferences_cache();
   Services.prefs.setCharPref("xpinstall.whitelist.add.TEST4", "https://whitelist4.example.com");
   Services.obs.notifyObservers(null, "flush-pending-permissions", "lolcats");
   Assert.equal(Services.prefs.getCharPref("xpinstall.whitelist.add.TEST4"), "https://whitelist4.example.com");
-}
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js
@@ -28,24 +28,22 @@ const PLUGINS = [
   new MockPlugin("test_newVersion", "1", Ci.nsIPluginTag.STATE_ENABLED),
   new MockPlugin("test_newVersion", "3", Ci.nsIPluginTag.STATE_ENABLED)
 ];
 
 /**
  * The entry point of the unit tests, which is also responsible of
  * copying the blocklist file to the profile folder.
  */
-function run_test() {
+add_task(async function setup() {
   copyBlocklistToProfile(do_get_file("data/pluginInfoURL_block.xml"));
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
-  startupManager();
-
-  run_next_test();
-}
+  await promiseStartupManager();
+});
 
 /**
  * Test that the blocklist service correctly loads and returns the infoURL for
  * a plugin that matches the first entry in the blocklist.
  */
 add_task(async function test_infoURL() {
   // The testInfoURL must match the value within the
   // <infoURL> tag in pluginInfoURL_block.xml.
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js
@@ -19,23 +19,23 @@ const PLUGINS = [
   new PluginTag("Flash", "A mock Flash plugin"),
   new PluginTag("Flash", "A mock Flash plugin")
 ];
 
 mockPluginHost(PLUGINS);
 
 // This verifies that when the list of plugins changes the add-ons manager
 // correctly updates
-function run_test() {
+async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   Services.prefs.setBoolPref("media.gmp-provider.enabled", false);
 
-  startupManager();
+  await promiseStartupManager();
   AddonManager.addAddonListener(AddonListener);
   AddonManager.addInstallListener(InstallListener);
 
   run_test_1();
 }
 
 function end_test() {
   executeSoon(do_test_finished);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
@@ -15,25 +15,25 @@ function setTestPluginState(state) {
     if (tag.description == TEST_PLUGIN_DESCRIPTION) {
       tag.enabledState = state;
       return;
     }
   }
   throw Error("No plugin tag found for the test plugin");
 }
 
-function run_test() {
+async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   Services.prefs.setBoolPref("plugin.load_flash_only", false);
 
   setTestPluginState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
 
-  startupManager();
+  await promiseStartupManager();
   AddonManager.addAddonListener(AddonListener);
   AddonManager.addInstallListener(InstallListener);
 
   run_test_1();
 }
 
 // Finds the test plugin library
 function get_test_plugin() {
@@ -188,17 +188,17 @@ async function run_test_3(p) {
   Assert.ok(p2.isActive);
   Assert.equal(p2.name, "Shockwave Flash");
 
   executeSoon(run_test_4);
 }
 
 // Verify that after a restart the test plugin has the same ID
 async function run_test_4() {
-  restartManager();
+  await promiseRestartManager();
 
   let p = await AddonManager.getAddonByID(gID);
   Assert.notEqual(p, null);
   Assert.equal(p.name, "Shockwave Flash");
 
   Services.prefs.clearUserPref("plugins.click_to_play");
 
   executeSoon(do_test_finished);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
@@ -34,25 +34,25 @@ var gManagerEventsListener = {
         return aSeenEvent == event;
       });
       Assert.equal(matchingEvents.length, 1);
     }
     this.seenEvents = [];
   }
 };
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   Services.prefs.setBoolPref("extensions.update.enabled", true);
   Services.prefs.setBoolPref("extensions.update.autoUpdateDefault", true);
   Services.prefs.setBoolPref("extensions.strictCompatibility", true);
   Services.prefs.setBoolPref("extensions.checkUpdatesecurity", true);
 
-  startupManager();
+  await promiseStartupManager();
   gManagerEventsListener.init();
 
 
   // AddonManager.updateEnabled
   gManagerEventsListener.expect(["onUpdateModeChanged"]);
   AddonManager.updateEnabled = false;
   gManagerEventsListener.checkExpected();
   Assert.ok(!AddonManager.updateEnabled);
@@ -198,9 +198,9 @@ function run_test() {
     Assert.ok(!Services.prefs.prefHasUserValue("extensions.checkUpdateSecurity"));
 
   gManagerEventsListener.shutdown();
 
   // After removing the listener, ensure we get no further events.
   gManagerEventsListener.expect([]);
   AddonManager.updateEnabled = false;
   gManagerEventsListener.checkExpected();
-}
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js
@@ -23,20 +23,20 @@ function mockAddonProvider(name) {
 
   return mockProvider;
 }
 
 add_task(async function testMarkSafe() {
   info("Starting with provider normally");
   let provider = mockAddonProvider("Mock1");
   AddonManagerPrivate.registerProvider(provider);
-  startupManager();
+  await promiseStartupManager();
   ok(!provider.apiAccessed, "Provider API should not have been accessed");
   AddonManagerPrivate.unregisterProvider(provider);
   await promiseShutdownManager();
 
   info("Starting with provider that marks itself safe");
   provider.apiAccessed = false;
   provider.markSafe = true;
   AddonManagerPrivate.registerProvider(provider);
-  startupManager();
+  await promiseStartupManager();
   ok(provider.apiAccessed, "Provider API should have been accessed");
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js
@@ -55,17 +55,17 @@ add_task(async function blockRepoShutdow
   // the mock provider behaves enough like AddonRepository for the purpose of this test
   let mockRepo = mockAddonProvider("Mock repo");
   // Trigger the lazy getter so that we can assign a new value to it:
   void AMscope.AddonRepository;
   AMscope.AddonRepository = mockRepo;
 
   let mockProvider = mockAddonProvider("Mock provider");
 
-  startupManager();
+  await promiseStartupManager();
   AddonManagerPrivate.registerProvider(mockProvider);
 
   // Start shutting the manager down
   let managerDown = promiseShutdownManager();
 
   // Wait for manager to call provider shutdown.
   await mockProvider.shutdownPromise;
   // check AsyncShutdown state
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
@@ -33,17 +33,17 @@ function mockAddonProvider(name) {
 }
 
 add_task(async function unsafeProviderShutdown() {
   let firstProvider = mockAddonProvider("Mock1");
   AddonManagerPrivate.registerProvider(firstProvider);
   let secondProvider = mockAddonProvider("Mock2");
   AddonManagerPrivate.registerProvider(secondProvider);
 
-  startupManager();
+  await promiseStartupManager();
 
   let shutdownPromise = null;
   await new Promise(resolve => {
     secondProvider.shutdownCallback = function() {
       return AddonManager.getAddonByID("does-not-exist").then(() => {
         resolve();
       });
     };
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js
@@ -28,24 +28,24 @@ function mockAddonProvider(name) {
   };
 
   return mockProvider;
 }
 
 add_task(async function unsafeProviderStartup() {
   let secondProvider = null;
 
-  await new Promise(resolve => {
+  await new Promise(async resolve => {
     let firstProvider = mockAddonProvider("Mock1");
     firstProvider.startupCallback = function() {
       resolve(AddonManager.getAddonByID("does-not-exist"));
     };
     AddonManagerPrivate.registerProvider(firstProvider);
 
     secondProvider = mockAddonProvider("Mock2");
     AddonManagerPrivate.registerProvider(secondProvider);
 
-    startupManager();
+    await promiseStartupManager();
   });
 
   equal(startupOrder.join(","), ["Mock1", "Mock2"].join(","), "Mock providers should have hasStarted in expected order");
   ok(!secondProvider.unsafeAccess, "Second registered mock provider should not have been accessed unsafely");
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
@@ -90,32 +90,32 @@ async function run_proxy_tests() {
     addon.directory = gTmpD.clone();
     addon.directory.append(addon.id);
 
     addon.proxyFile = profileDir.clone();
     addon.proxyFile.append(addon.dirId || addon.id);
 
     METADATA.id = addon.id;
     METADATA.name = addon.id;
-    writeInstallRDFToDir(METADATA, gTmpD);
+    await promiseWriteInstallRDFToDir(METADATA, gTmpD);
 
     if (addon.type == "proxy") {
       await promiseWriteFile(addon.proxyFile, addon.directory.path);
     } else if (addon.type == "symlink") {
       await createSymlink(addon.directory, addon.proxyFile);
     }
   }
 
-  startupManager();
+  await promiseStartupManager();
 
   // Check that all add-ons original sources still exist after invalid
   // add-ons have been removed at startup.
   checkAddonsExist();
 
-  return AddonManager.getAddonsByIDs(ADDONS.map(addon => addon.id)).then(addons => {
+  return AddonManager.getAddonsByIDs(ADDONS.map(addon => addon.id)).then(async addons => {
     try {
       for (let [i, addon] of addons.entries()) {
         // Ensure that valid proxied add-ons were installed properly on
         // platforms that support the installation method.
         print(ADDONS[i].id,
               ADDONS[i].dirId,
               ADDONS[i].dirId != null,
               ADDONS[i].type == "symlink");
@@ -144,20 +144,20 @@ async function run_proxy_tests() {
                        fixURL(addon.getResourceURI("install.rdf").spec),
                        `Resource URLs resolve as expected`);
 
           addon.uninstall();
         }
       }
 
       // Check that original sources still exist after explicit uninstall.
-      restartManager();
+      await promiseRestartManager();
       checkAddonsExist();
 
-      shutdownManager();
+      await promiseShutdownManager();
 
       // Check that all of the proxy files have been removed and remove
       // the original targets.
       for (let addon of ADDONS) {
         equal(addon.proxyFile.exists(), addon.dirId != null,
               `Proxy file ${addon.proxyFile.path} should exist?`);
         addon.directory.remove(true);
         try {
@@ -183,37 +183,37 @@ async function run_symlink_tests() {
 
   let tempFile = tempDirectory.clone();
   tempFile.append("test.txt");
   tempFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
 
   let addonDirectory = profileDir.clone();
   addonDirectory.append(METADATA.id);
 
-  writeInstallRDFToDir(METADATA, profileDir);
+  await promiseWriteInstallRDFToDir(METADATA, profileDir);
 
   let symlink = addonDirectory.clone();
   symlink.append(tempDirectory.leafName);
   await createSymlink(tempDirectory, symlink);
 
   // Make sure that the symlink was created properly.
   let file = symlink.clone();
   file.append(tempFile.leafName);
   file.normalize();
   Assert.equal(file.path.replace(/^\/private\//, "/"), tempFile.path);
 
-  startupManager();
+  await promiseStartupManager();
 
-  return AddonManager.getAddonByID(METADATA.id).then(addon => {
+  return AddonManager.getAddonByID(METADATA.id).then(async addon => {
     Assert.notEqual(addon, null);
 
     addon.uninstall();
 
-    restartManager();
-    shutdownManager();
+    await promiseRestartManager();
+    await promiseShutdownManager();
 
     // Check that the install directory is gone.
     Assert.ok(!addonDirectory.exists());
 
     // Check that the temp file is not gone.
     Assert.ok(tempFile.exists());
 
     tempDirectory.remove(true);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_proxy.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_proxy.js
@@ -7,17 +7,17 @@ const ID = "proxy1@tests.mozilla.org";
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
 startupManager();
 
 BootstrapMonitor.init();
 
 // Ensure that a proxy file to an add-on with a valid manifest works.
 add_task(async function() {
   let tempdir = gTmpD.clone();
-  writeInstallRDFToDir({
+  await promiseWriteInstallRDFToDir({
     id: ID,
     version: "1.0",
     bootstrap: true,
     unpack: true,
     targetApplications: [{
           id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
@@ -28,17 +28,17 @@ add_task(async function() {
   let unpackedAddon = tempdir.clone();
   unpackedAddon.append(ID);
   do_get_file("data/test_proxy/bootstrap.js")
     .copyTo(unpackedAddon, "bootstrap.js");
 
   // create proxy file in profile/extensions dir
   let extensionsDir = gProfD.clone();
   extensionsDir.append("extensions");
-  let proxyFile = writeProxyFileToDir(extensionsDir, unpackedAddon, ID);
+  let proxyFile = await promiseWriteProxyFileToDir(extensionsDir, unpackedAddon, ID);
 
   await promiseRestartManager();
 
   BootstrapMonitor.checkAddonInstalled(ID, "1.0");
   BootstrapMonitor.checkAddonStarted(ID, "1.0");
 
   let addon = await promiseAddonByID(ID);
 
@@ -61,17 +61,17 @@ add_task(async function() {
 
 
 // Ensure that a proxy file to an add-on is not removed even
 // if the manifest file is invalid. See bug 1195353.
 add_task(async function() {
   let tempdir = gTmpD.clone();
 
   // use a mismatched ID to make this install.rdf invalid
-  writeInstallRDFToDir({
+  await promiseWriteInstallRDFToDir({
     id: "bad-proxy1@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     unpack: true,
     targetApplications: [{
           id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
@@ -82,17 +82,17 @@ add_task(async function() {
   let unpackedAddon = tempdir.clone();
   unpackedAddon.append(ID);
   do_get_file("data/test_proxy/bootstrap.js")
     .copyTo(unpackedAddon, "bootstrap.js");
 
   // create proxy file in profile/extensions dir
   let extensionsDir = gProfD.clone();
   extensionsDir.append("extensions");
-  let proxyFile = writeProxyFileToDir(extensionsDir, unpackedAddon, ID);
+  let proxyFile = await promiseWriteProxyFileToDir(extensionsDir, unpackedAddon, ID);
 
   await promiseRestartManager();
 
   BootstrapMonitor.checkAddonNotInstalled(ID, "1.0");
   BootstrapMonitor.checkAddonNotStarted(ID, "1.0");
 
   let addon = await promiseAddonByID(ID);
   Assert.equal(addon, null);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_registry.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_registry.js
@@ -34,24 +34,27 @@ var addon2 = {
   }]
 };
 
 const IDS = ["addon1@tests.mozilla.org",
              "addon2@tests.mozilla.org",
              "addon3@tests.mozilla.org"];
 
 
-const addon1Dir = writeInstallRDFForExtension(addon1, gProfD, "addon1");
-const addon2Dir = writeInstallRDFForExtension(addon2, gProfD, "addon2");
+var addon1Dir;
+var addon2Dir;
 const addon3Dir = gProfD.clone();
 addon3Dir.append("addon3@tests.mozilla.org");
 
 let registry;
 
 add_task(async function setup() {
+  addon1Dir = await promiseWriteInstallRDFForExtension(addon1, gProfD, "addon1");
+  addon2Dir = await promiseWriteInstallRDFForExtension(addon2, gProfD, "addon2");
+
   registry = new MockRegistry();
   registerCleanupFunction(() => {
     registry.shutdown();
   });
 });
 
 // Tests whether basic registry install works
 add_task(async function test_1() {
@@ -144,17 +147,17 @@ add_task(async function test_4() {
   await promiseRestartManager();
 
   registry.setValue(Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
                     "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
                     "addon1@tests.mozilla.org", null);
   registry.setValue(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
                     "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
                     "addon2@tests.mozilla.org", addon1Dir.path);
-  writeInstallRDFForExtension(addon2, gProfD, "addon1");
+  await promiseWriteInstallRDFForExtension(addon2, gProfD, "addon1");
 
   await promiseRestartManager();
 
   let [a1, a2, a3] = await AddonManager.getAddonsByIDs(IDS);
   equal(a1, null);
   notEqual(a2, null);
   equal(a3, null);
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_reload.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_reload.js
@@ -175,27 +175,27 @@ add_task(async function test_reload_to_i
 
 add_task(async function test_manifest_changes_are_refreshed() {
   if (!AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS) {
     return;
   }
   await promiseRestartManager();
   let tempdir = gTmpD.clone();
 
-  const unpackedAddon = writeInstallRDFToDir(
+  const unpackedAddon = await promiseWriteInstallRDFToDir(
     Object.assign({}, manifestSample, {
       name: "Test Bootstrap 1",
     }), tempdir, manifestSample.id, "bootstrap.js");
 
   await AddonManager.installTemporaryAddon(unpackedAddon);
   const addon = await promiseAddonByID(manifestSample.id);
   notEqual(addon, null);
   equal(addon.name, "Test Bootstrap 1");
 
-  writeInstallRDFToDir(Object.assign({}, manifestSample, {
+  await promiseWriteInstallRDFToDir(Object.assign({}, manifestSample, {
     name: "Test Bootstrap 1 (reloaded)",
   }), tempdir, manifestSample.id);
 
   await addon.reload();
 
   const reloadedAddon = await promiseAddonByID(manifestSample.id);
   notEqual(reloadedAddon, null);
   equal(reloadedAddon.name, "Test Bootstrap 1 (reloaded)");
@@ -206,27 +206,27 @@ add_task(async function test_manifest_ch
 
 add_task(async function test_reload_fails_on_installation_errors() {
   if (!AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS) {
     return;
   }
   await promiseRestartManager();
   let tempdir = gTmpD.clone();
 
-  const unpackedAddon = writeInstallRDFToDir(
+  const unpackedAddon = await promiseWriteInstallRDFToDir(
     Object.assign({}, manifestSample, {
       name: "Test Bootstrap 1",
     }), tempdir, manifestSample.id, "bootstrap.js");
 
   await AddonManager.installTemporaryAddon(unpackedAddon);
   const addon = await promiseAddonByID(manifestSample.id);
   notEqual(addon, null);
 
   // Trigger an installation error with an empty manifest.
-  writeInstallRDFToDir({}, tempdir, manifestSample.id);
+  await promiseWriteInstallRDFToDir({}, tempdir, manifestSample.id);
 
   await Assert.rejects(addon.reload(), /No ID in install manifest/);
 
   // The old add-on should be active. I.E. the broken reload will not
   // disturb it.
   const oldAddon = await promiseAddonByID(manifestSample.id);
   notEqual(oldAddon, null);
   equal(oldAddon.isActive, true);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_safemode.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_safemode.js
@@ -27,23 +27,23 @@ profileDir.append("extensions");
 var gIconURL = null;
 
 // Sets up the profile by installing an add-on.
 async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   gAppInfo.inSafeMode = true;
 
-  startupManager();
+  await promiseStartupManager();
 
   let a1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.equal(a1, null);
   do_check_not_in_crash_annotation(addon1.id, addon1.version);
 
-  writeInstallRDFForExtension(addon1, profileDir, addon1.id, "icon.png");
+  await promiseWriteInstallRDFForExtension(addon1, profileDir, addon1.id, "icon.png");
   gIconURL = do_get_addon_root_uri(profileDir.clone(), addon1.id) + "icon.png";
 
   await promiseRestartManager();
 
   let newa1 = await AddonManager.getAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(newa1, null);
   Assert.ok(!newa1.isActive);
   Assert.ok(!newa1.userDisabled);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_seen.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_seen.js
@@ -64,17 +64,17 @@ add_task(async function() {
   registerDirectory("XRESysSExtPD", systemParentDir.clone());
   registerCleanupFunction(() => {
     systemParentDir.remove(true);
   });
 
   let systemDir = systemParentDir.clone();
   systemDir.append(Services.appinfo.ID);
 
-  let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), systemDir, ID);
+  let path = await manuallyInstall(do_get_addon("test_bootstrap1_1"), systemDir, ID);
   // Make sure the startup code will detect sideloaded updates
   setExtensionModifiedTime(path, Date.now() - 10000);
 
   await promiseStartupManager();
   await AddonManagerPrivate.getNewSideloads();
 
   let addon = await promiseAddonByID(ID);
   Assert.equal(addon.version, "1.0");
@@ -92,17 +92,17 @@ add_task(async function() {
   path.remove(true);
 
   Services.prefs.setIntPref("extensions.startupScanScopes", savedStartupScanScopes);
 });
 
 // Sideloading an add-on in the profile should mark it as unseen and it should
 // remain unseen after an update is sideloaded.
 add_task(async function() {
-  let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
+  let path = await manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
   // Make sure the startup code will detect sideloaded updates
   setExtensionModifiedTime(path, Date.now() - 10000);
 
   await promiseStartupManager();
 
   let addon = await promiseAddonByID(ID);
   Assert.equal(addon.version, "1.0");
   Assert.ok(addon.foreignInstall);
@@ -113,34 +113,34 @@ add_task(async function() {
   addon = await promiseAddonByID(ID);
   Assert.ok(addon.foreignInstall);
   Assert.ok(!addon.seen);
 
   await promiseShutdownManager();
 
   // Sideloading an update shouldn't change the state
   manuallyUninstall(profileDir, ID);
-  manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, ID);
+  await manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, ID);
   setExtensionModifiedTime(path, Date.now());
 
   await promiseStartupManager();
 
   addon = await promiseAddonByID(ID);
   Assert.equal(addon.version, "2.0");
   Assert.ok(addon.foreignInstall);
   Assert.ok(!addon.seen);
 
   addon.uninstall();
   await promiseShutdownManager();
 });
 
 // Sideloading an add-on in the profile should mark it as unseen and it should
 // remain unseen after a regular update.
 add_task(async function() {
-  let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
+  let path = await manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
   // Make sure the startup code will detect sideloaded updates
   setExtensionModifiedTime(path, Date.now() - 10000);
 
   await promiseStartupManager();
 
   let addon = await promiseAddonByID(ID);
   Assert.equal(addon.version, "1.0");
   Assert.ok(addon.foreignInstall);
@@ -170,17 +170,17 @@ add_task(async function() {
 
   addon.uninstall();
   await promiseShutdownManager();
 });
 
 // After a sideloaded addon has been seen, sideloading an update should
 // not reset it to unseen.
 add_task(async function() {
-  let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
+  let path = await manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
   // Make sure the startup code will detect sideloaded updates
   setExtensionModifiedTime(path, Date.now() - 10000);
 
   await promiseStartupManager();
 
   let addon = await promiseAddonByID(ID);
   Assert.equal(addon.version, "1.0");
   Assert.ok(addon.foreignInstall);
@@ -193,34 +193,34 @@ add_task(async function() {
   addon = await promiseAddonByID(ID);
   Assert.ok(addon.foreignInstall);
   Assert.ok(addon.seen);
 
   await promiseShutdownManager();
 
   // Sideloading an update shouldn't change the state
   manuallyUninstall(profileDir, ID);
-  manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, ID);
+  await manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, ID);
   setExtensionModifiedTime(path, Date.now());
 
   await promiseStartupManager();
 
   addon = await promiseAddonByID(ID);
   Assert.equal(addon.version, "2.0");
   Assert.ok(addon.foreignInstall);
   Assert.ok(addon.seen);
 
   addon.uninstall();
   await promiseShutdownManager();
 });
 
 // After a sideloaded addon has been seen, manually applying an update should
 // not reset it to unseen.
 add_task(async function() {
-  let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
+  let path = await manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
   // Make sure the startup code will detect sideloaded updates
   setExtensionModifiedTime(path, Date.now() - 10000);
 
   await promiseStartupManager();
 
   let addon = await promiseAddonByID(ID);
   Assert.equal(addon.version, "1.0");
   Assert.ok(addon.foreignInstall);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js
@@ -77,17 +77,17 @@ async function test_functions() {
       if (e.result != Cr.NS_ERROR_NOT_INITIALIZED)
         do_throw(prop + " threw an unexpected exception: " + e);
     }
   }
 }
 
 add_task(async function() {
   await test_functions();
-  startupManager();
-  shutdownManager();
+  await promiseStartupManager();
+  await promiseShutdownManager();
   await test_functions();
 });
 
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   run_next_test();
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
@@ -60,33 +60,31 @@ function clearCache(file) {
 
   Services.obs.notifyObservers(file, "flush-cache-entry");
 }
 
 function getActiveVersion() {
   return Services.prefs.getIntPref("bootstraptest.active_version");
 }
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
 
   // Start and stop the manager to initialise everything in the profile before
   // actual testing
-  startupManager();
-  shutdownManager();
+  await promiseStartupManager();
+  await promiseShutdownManager();
   resetPrefs();
-
-  run_next_test();
-}
+});
 
 // Injecting into profile (bootstrap)
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.unsigned), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.unsigned), profileDir, ID);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(addon.appDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
   Assert.equal(getActiveVersion(), -1);
@@ -95,20 +93,20 @@ add_task(async function() {
   await promiseShutdownManager();
   resetPrefs();
 
   Assert.ok(!file.exists());
   clearCache(file);
 });
 
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
   breakAddon(file);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(addon.appDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   Assert.equal(getActiveVersion(), -1);
@@ -117,19 +115,19 @@ add_task(async function() {
   await promiseShutdownManager();
   resetPrefs();
 
   Assert.ok(!file.exists());
   clearCache(file);
 });
 
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.badid), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.badid), profileDir, ID);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(addon.appDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   Assert.equal(getActiveVersion(), -1);
@@ -139,39 +137,39 @@ add_task(async function() {
   resetPrefs();
 
   Assert.ok(!file.exists());
   clearCache(file);
 });
 
 // Installs a signed add-on then modifies it in place breaking its signing
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
 
   // Make it appear to come from the past so when we modify it later it is
   // detected during startup. Obviously malware can bypass this method of
   // detection but the periodic scan will catch that
   await promiseSetExtensionModifiedTime(file.path, Date.now() - 600000);
 
-  startupManager();
+  await promiseStartupManager();
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
   Assert.equal(getActiveVersion(), 2);
 
   await promiseShutdownManager();
   Assert.equal(getActiveVersion(), 0);
 
   clearCache(file);
   breakAddon(file);
   resetPrefs();
 
-  startupManager();
+  await promiseStartupManager();
 
   addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(addon.appDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   Assert.equal(getActiveVersion(), -1);
 
@@ -184,19 +182,19 @@ add_task(async function() {
   resetPrefs();
 
   Assert.ok(!file.exists());
   clearCache(file);
 });
 
 // Injecting into profile (non-bootstrap)
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.unsigned), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.unsigned), profileDir, ID);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(addon.appDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
   Assert.ok(!isExtensionInAddonsList(profileDir, ID));
@@ -205,20 +203,20 @@ add_task(async function() {
   await promiseRestartManager();
   await promiseShutdownManager();
 
   Assert.ok(!file.exists());
   clearCache(file);
 });
 
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
   breakAddon(file);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(addon.appDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   Assert.ok(!isExtensionInAddonsList(profileDir, ID));
@@ -227,19 +225,19 @@ add_task(async function() {
   await promiseRestartManager();
   await promiseShutdownManager();
 
   Assert.ok(!file.exists());
   clearCache(file);
 });
 
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.badid), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.badid), profileDir, ID);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Currently we leave the sideloaded add-on there but just don't run it
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(addon.appDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
   Assert.ok(!isExtensionInAddonsList(profileDir, ID));
@@ -249,17 +247,17 @@ add_task(async function() {
   await promiseShutdownManager();
 
   Assert.ok(!file.exists());
   clearCache(file);
 });
 
 // Installs a signed add-on then modifies it in place breaking its signing
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
 
   // Make it appear to come from the past so when we modify it later it is
   // detected during startup. Obviously malware can bypass this method of
   // detection but the periodic scan will catch that
   await promiseSetExtensionModifiedTime(file.path, Date.now() - 60000);
 
   await promiseStartupManager();
   let addon = await promiseAddonByID(ID);
@@ -292,64 +290,64 @@ add_task(async function() {
   await promiseShutdownManager();
 
   Assert.ok(!file.exists());
   clearCache(file);
 });
 
 // Stage install then modify before startup (non-bootstrap)
 add_task(async function() {
-  startupManager();
+  await promiseStartupManager();
   await promiseInstallAllFiles([do_get_file(DATA + ADDONS.nonbootstrap.signed)]);
   await promiseShutdownManager();
 
   let staged = profileDir.clone();
   staged.append("staged");
   staged.append(do_get_expected_addon_name(ID));
   Assert.ok(staged.exists());
 
   breakAddon(staged);
-  startupManager();
+  await promiseStartupManager();
 
   // Should have refused to install the broken staged version
   let addon = await promiseAddonByID(ID);
   Assert.equal(addon, null);
 
   clearCache(staged);
 
   await promiseShutdownManager();
 });
 
 // Manufacture staged install (bootstrap)
 add_task(async function() {
   let stage = profileDir.clone();
   stage.append("staged");
 
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), stage, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), stage, ID);
   breakAddon(file);
 
-  startupManager();
+  await promiseStartupManager();
 
   // Should have refused to install the broken staged version
   let addon = await promiseAddonByID(ID);
   Assert.equal(addon, null);
   Assert.equal(getActiveVersion(), -1);
 
   Assert.ok(!file.exists());
   clearCache(file);
 
   await promiseShutdownManager();
   resetPrefs();
 });
 
 // Preliminarily-signed sideloaded add-ons should work
 add_task(async function() {
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.preliminary), profileDir, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.preliminary), profileDir, ID);
 
-  startupManager();
+  await promiseStartupManager();
 
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_PRELIMINARY);
   Assert.equal(getActiveVersion(), 2);
 
@@ -361,19 +359,19 @@ add_task(async function() {
   clearCache(file);
 });
 
 // Preliminarily-signed sideloaded add-ons should work via staged install
 add_task(async function() {
   let stage = profileDir.clone();
   stage.append("staged");
 
-  let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.preliminary), stage, ID);
+  let file = await manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.preliminary), stage, ID);
 
-  startupManager();
+  await promiseStartupManager();
 
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_PRELIMINARY);
   Assert.equal(getActiveVersion(), 2);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
@@ -172,22 +172,20 @@ async function test_update_working(file,
   Assert.equal(install.addon.signedState, expectedSignedState);
 
   gServer.registerFile("/" + file.leafName, null);
   gServer.registerPathHandler("/update.rdf", null);
 
   install.addon.uninstall();
 }
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
-  startupManager();
-
-  run_next_test();
-}
+  await promiseStartupManager();
+});
 
 // Try to install a broken add-on
 add_task(async function() {
   let file = createBrokenAddonModify(do_get_file(DATA + ADDONS.bootstrap.signed));
   await test_install_broken(file, AddonManager.ERROR_CORRUPT_FILE);
   file.remove(true);
 });
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js
@@ -4,22 +4,20 @@ Services.prefs.setBoolPref(PREF_EM_CHECK
 gUseRealCertChecks = true;
 
 const DATA = "data/signing_checks/";
 
 const ID_63 = "123456789012345678901234567890123456789012345@tests.mozilla.org";
 const ID_64 = "1234567890123456789012345678901234567890123456@tests.mozilla.org";
 const ID_65 = "12345678901234567890123456789012345678901234568@tests.mozilla.org";
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-  startupManager();
-
-  run_next_test();
-}
+  await promiseStartupManager();
+});
 
 // Installs the cases that should be working
 add_task(async function test_working() {
   await promiseInstallAllFiles([do_get_file(DATA + "long_63_plain.xpi"),
                                 do_get_file(DATA + "long_64_plain.xpi"),
                                 do_get_file(DATA + "long_65_hash.xpi")]);
 
   let addons = await promiseAddonsByIDs([ID_63, ID_64, ID_65]);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js
@@ -36,47 +36,45 @@ function verifySignatures() {
     Services.obs.addObserver(observer, "xpi-signature-changed");
 
     info("Verifying signatures");
     let XPIscope = ChromeUtils.import("resource://gre/modules/addons/XPIProvider.jsm", {});
     XPIscope.XPIProvider.verifySignatures();
   });
 }
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
 
   // Start and stop the manager to initialise everything in the profile before
   // actual testing
-  startupManager();
-  shutdownManager();
-
-  run_next_test();
-}
+  await promiseStartupManager();
+  await promiseShutdownManager();
+});
 
 // Updating the pref without changing the app version won't disable add-ons
 // immediately but will after a signing check
 add_task(async function() {
   Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, false);
-  startupManager();
+  await promiseStartupManager();
 
   // Install the signed add-on
   await promiseInstallAllFiles([do_get_file(DATA + "unsigned_bootstrap_2.xpi")]);
 
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
 
   await promiseShutdownManager();
 
   Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
 
-  startupManager();
+  await promiseStartupManager();
 
   addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
 
   // Update checks shouldn't affect the add-on
@@ -102,32 +100,32 @@ add_task(async function() {
 
   await promiseShutdownManager();
 });
 
 // Updating the pref with changing the app version will disable add-ons
 // immediately
 add_task(async function() {
   Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, false);
-  startupManager();
+  await promiseStartupManager();
 
   // Install the signed add-on
   await promiseInstallAllFiles([do_get_file(DATA + "unsigned_bootstrap_2.xpi")]);
 
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(!addon.appDisabled);
   Assert.ok(addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
 
   await promiseShutdownManager();
 
   Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
   gAppInfo.version = 5.0;
-  startupManager();
+  await promiseStartupManager();
 
   addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.ok(addon.appDisabled);
   Assert.ok(!addon.isActive);
   Assert.equal(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
 
   addon.uninstall();
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js
@@ -45,29 +45,29 @@ function run_test() {
   run_next_test();
 }
 
 function verify_no_change([startFile, startState], [endFile, endState]) {
   add_task(async function() {
     info("A switch from " + startFile + " to " + endFile + " should cause no change.");
 
     // Install the first add-on
-    manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
-    startupManager();
+    await manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
+    await promiseStartupManager();
 
     let addon = await promiseAddonByID(ID);
     Assert.notEqual(addon, null);
     let wasAppDisabled = addon.appDisabled;
     Assert.notEqual(addon.appDisabled, addon.isActive);
     Assert.equal(addon.pendingOperations, AddonManager.PENDING_NONE);
     Assert.equal(addon.signedState, startState);
 
     // Swap in the files from the next add-on
     manuallyUninstall(profileDir, ID);
-    manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
+    await manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
 
     let events = {
       [ID]: []
     };
 
     if (startState != endState)
       events[ID].unshift(["onPropertyChanged", ["signedState"]]);
 
@@ -90,28 +90,28 @@ function verify_no_change([startFile, st
   });
 }
 
 function verify_enables([startFile, startState], [endFile, endState]) {
   add_task(async function() {
     info("A switch from " + startFile + " to " + endFile + " should enable the add-on.");
 
     // Install the first add-on
-    manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
-    startupManager();
+    await manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
+    await promiseStartupManager();
 
     let addon = await promiseAddonByID(ID);
     Assert.notEqual(addon, null);
     Assert.ok(!addon.isActive);
     Assert.equal(addon.pendingOperations, AddonManager.PENDING_NONE);
     Assert.equal(addon.signedState, startState);
 
     // Swap in the files from the next add-on
     manuallyUninstall(profileDir, ID);
-    manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
+    await manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
 
     let needsRestart = hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE);
     info(needsRestart);
 
     let events = {};
     if (!needsRestart) {
       events[ID] = [
         ["onPropertyChanged", ["appDisabled"]],
@@ -152,30 +152,30 @@ function verify_enables([startFile, star
   });
 }
 
 function verify_disables([startFile, startState], [endFile, endState]) {
   add_task(async function() {
     info("A switch from " + startFile + " to " + endFile + " should disable the add-on.");
 
     // Install the first add-on
-    manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
-    startupManager();
+    await manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
+    await promiseStartupManager();
 
     let addon = await promiseAddonByID(ID);
     Assert.notEqual(addon, null);
     Assert.ok(addon.isActive);
     Assert.equal(addon.pendingOperations, AddonManager.PENDING_NONE);
     Assert.equal(addon.signedState, startState);
 
     let needsRestart = hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE);
 
     // Swap in the files from the next add-on
     manuallyUninstall(profileDir, ID);
-    manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
+    await manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
 
     let events = {};
     if (!needsRestart) {
       events[ID] = [
         ["onPropertyChanged", ["appDisabled"]],
         ["onDisabling", false],
         "onDisabled"
       ];
--- a/toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js
@@ -64,29 +64,29 @@ function load_blocklist(aFile) {
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
   run_next_test();
 }
 
 // Tests that an appDisabled add-on that becomes softBlocked remains disabled
 // when becoming appEnabled
 add_task(async function() {
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "softblock1@tests.mozilla.org",
     version: "1.0",
     name: "Softblocked add-on",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "2",
       maxVersion: "3"
     }]
   }, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let s1 = await promiseAddonByID("softblock1@tests.mozilla.org");
 
   // Make sure to mark it as previously enabled.
   s1.userDisabled = false;
 
   Assert.ok(!s1.softDisabled);
   Assert.ok(s1.appDisabled);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js
@@ -73,25 +73,25 @@ async function run_test() {
     response.write(JSON.stringify(COMPAT_RESPONSE));
   });
 
   Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, `${BASE_URL}/addons.json`);
   Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES, `${BASE_URL}/compat.json`);
   Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-  writeInstallRDFForExtension(addon, profileDir);
-  startupManager();
+  await promiseWriteInstallRDFForExtension(addon, profileDir);
+  await promiseStartupManager();
 
   let a = await AddonManager.getAddonByID("addon@tests.mozilla.org");
   Assert.notEqual(a, null);
   Assert.equal(a.sourceURI, null);
 
   backgroundUpdate(async function() {
-    restartManager();
+    await promiseRestartManager();
 
     let a2 = await AddonManager.getAddonByID("addon@tests.mozilla.org");
     Assert.notEqual(a2, null);
     Assert.notEqual(a2.sourceURI, null);
     Assert.equal(a2.sourceURI.spec, "http://www.example.com/testaddon.xpi");
 
     do_test_finished();
   });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_startup.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_startup.js
@@ -127,27 +127,25 @@ async function run_test() {
   do_test_pending("test_startup main");
 
   Services.obs.addObserver({
     observe(aSubject, aTopic, aData) {
       gCachePurged = true;
     }
   }, "startupcache-invalidate");
 
-  startupManager();
+  await promiseStartupManager();
   check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
 
   Assert.ok(!gExtensionsJSON.exists());
 
-  Assert.ok(!gAddonStartup.exists());
-
   let [a1, a2, a3, a4, a5] = await AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                                                 "addon2@tests.mozilla.org",
                                                                 "addon3@tests.mozilla.org",
                                                                 "addon4@tests.mozilla.org",
                                                                 "addon5@tests.mozilla.org"]);
   Assert.equal(a1, null);
   do_check_not_in_crash_annotation(addon1.id, addon1.version);
   Assert.equal(a2, null);
@@ -161,27 +159,27 @@ async function run_test() {
 }
 
 function end_test() {
   do_test_finished("test_startup main");
 }
 
 // Try to install all the items into the profile
 async function run_test_1() {
-  writeInstallRDFForExtension(addon1, profileDir);
-  var dest = writeInstallRDFForExtension(addon2, profileDir);
+  await promiseWriteInstallRDFForExtension(addon1, profileDir);
+  var dest = await promiseWriteInstallRDFForExtension(addon2, profileDir);
   // Attempt to make this look like it was added some time in the past so
   // the change in run_test_2 makes the last modified time change.
   setExtensionModifiedTime(dest, dest.lastModifiedTime - 5000);
 
-  writeInstallRDFForExtension(addon3, profileDir);
-  writeInstallRDFForExtension(addon4, profileDir, "addon4@tests.mozilla.org");
-  writeInstallRDFForExtension(addon5, profileDir);
-  writeInstallRDFForExtension(addon6, profileDir);
-  writeInstallRDFForExtension(addon7, profileDir);
+  await promiseWriteInstallRDFForExtension(addon3, profileDir);
+  await promiseWriteInstallRDFForExtension(addon4, profileDir, "addon4@tests.mozilla.org");
+  await promiseWriteInstallRDFForExtension(addon5, profileDir);
+  await promiseWriteInstallRDFForExtension(addon6, profileDir);
+  await promiseWriteInstallRDFForExtension(addon7, profileDir);
 
   gCachePurged = false;
   await promiseRestartManager();
   check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, ["addon1@tests.mozilla.org",
                                       "addon2@tests.mozilla.org",
                                       "addon3@tests.mozilla.org"]);
   check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
@@ -278,23 +276,23 @@ async function run_test_1() {
 }
 
 // Test that modified items are detected and items in other install locations
 // are ignored
 async function run_test_2() {
   await promiseShutdownManager();
 
   addon1.version = "1.1";
-  writeInstallRDFForExtension(addon1, userDir);
+  await promiseWriteInstallRDFForExtension(addon1, userDir);
   addon2.version = "2.1";
-  writeInstallRDFForExtension(addon2, profileDir);
+  await promiseWriteInstallRDFForExtension(addon2, profileDir);
   addon2.version = "2.2";
-  writeInstallRDFForExtension(addon2, globalDir);
+  await promiseWriteInstallRDFForExtension(addon2, globalDir);
   addon2.version = "2.3";
-  writeInstallRDFForExtension(addon2, userDir);
+  await promiseWriteInstallRDFForExtension(addon2, userDir);
   var dest = profileDir.clone();
   dest.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
   dest.remove(true);
 
   gCachePurged = false;
   await promiseStartupManager();
 
   check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
@@ -352,17 +350,17 @@ async function run_test_3() {
   await promiseShutdownManager();
 
   var dest = profileDir.clone();
   dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
   dest.remove(true);
   dest = profileDir.clone();
   dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
   dest.remove(true);
-  writeInstallRDFForExtension(addon3, profileDir, "addon4@tests.mozilla.org");
+  await promiseWriteInstallRDFForExtension(addon3, profileDir, "addon4@tests.mozilla.org");
 
   gCachePurged = false;
   await promiseStartupManager();
 
   check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, ["addon1@tests.mozilla.org",
                                     "addon2@tests.mozilla.org"]);
   check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
@@ -526,17 +524,17 @@ async function run_test_6() {
   executeSoon(run_test_7);
 }
 
 // Check that items in the profile hide the others again.
 async function run_test_7() {
   await promiseShutdownManager();
 
   addon1.version = "1.2";
-  writeInstallRDFForExtension(addon1, profileDir);
+  await promiseWriteInstallRDFForExtension(addon1, profileDir);
   var dest = userDir.clone();
   dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
   dest.remove(true);
 
   gCachePurged = false;
   await promiseStartupManager();
 
   check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
@@ -627,17 +625,17 @@ async function run_test_9() {
 
   var dest = userDir.clone();
   dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
   dest.remove(true);
   dest = globalDir.clone();
   dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
   dest.remove(true);
   addon2.version = "2.4";
-  writeInstallRDFForExtension(addon2, profileDir);
+  await promiseWriteInstallRDFForExtension(addon2, profileDir);
 
   gCachePurged = false;
   await promiseStartupManager();
 
   check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, ["addon2@tests.mozilla.org"]);
   check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
@@ -684,17 +682,17 @@ async function run_test_9() {
 // for the same item is handled
 async function run_test_10() {
   await promiseShutdownManager();
 
   var dest = profileDir.clone();
   dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
   dest.remove(true);
   addon1.version = "1.3";
-  writeInstallRDFForExtension(addon1, userDir);
+  await promiseWriteInstallRDFForExtension(addon1, userDir);
 
   gCachePurged = false;
   await promiseStartupManager();
 
   check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, ["addon1@tests.mozilla.org"]);
   check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
@@ -789,23 +787,23 @@ async function run_test_11() {
 
   executeSoon(run_test_12);
 }
 
 // Test that auto-disabling for specific scopes works
 async function run_test_12() {
   Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_USER);
 
-  shutdownManager();
+  await promiseShutdownManager();
 
-  writeInstallRDFForExtension(addon1, profileDir);
-  writeInstallRDFForExtension(addon2, userDir);
-  writeInstallRDFForExtension(addon3, globalDir);
+  await promiseWriteInstallRDFForExtension(addon1, profileDir);
+  await promiseWriteInstallRDFForExtension(addon2, userDir);
+  await promiseWriteInstallRDFForExtension(addon3, globalDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [a1, a2, a3] = await AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                                         "addon2@tests.mozilla.org",
                                                         "addon3@tests.mozilla.org"]);
   Assert.notEqual(a1, null);
   Assert.ok(!a1.userDisabled);
   Assert.ok(a1.seen);
   Assert.ok(a1.isActive);
@@ -815,38 +813,38 @@ async function run_test_12() {
   Assert.ok(!a2.seen);
   Assert.ok(!a2.isActive);
 
   Assert.notEqual(a3, null);
   Assert.ok(!a3.userDisabled);
   Assert.ok(a3.seen);
   Assert.ok(a3.isActive);
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   var dest = profileDir.clone();
   dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
   dest.remove(true);
   dest = userDir.clone();
   dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
   dest.remove(true);
   dest = globalDir.clone();
   dest.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
   dest.remove(true);
 
-  startupManager();
-  shutdownManager();
+  await promiseStartupManager();
+  await promiseShutdownManager();
 
   Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_SYSTEM);
 
-  writeInstallRDFForExtension(addon1, profileDir);
-  writeInstallRDFForExtension(addon2, userDir);
-  writeInstallRDFForExtension(addon3, globalDir);
+  await promiseWriteInstallRDFForExtension(addon1, profileDir);
+  await promiseWriteInstallRDFForExtension(addon2, userDir);
+  await promiseWriteInstallRDFForExtension(addon3, globalDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [a1_2, a2_2, a3_2] = await AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                                               "addon2@tests.mozilla.org",
                                                               "addon3@tests.mozilla.org"]);
   Assert.notEqual(a1_2, null);
   Assert.ok(!a1_2.userDisabled);
   Assert.ok(a1_2.seen);
   Assert.ok(a1_2.isActive);
@@ -856,38 +854,38 @@ async function run_test_12() {
   Assert.ok(a2_2.seen);
   Assert.ok(a2_2.isActive);
 
   Assert.notEqual(a3_2, null);
   Assert.ok(a3_2.userDisabled);
   Assert.ok(!a3_2.seen);
   Assert.ok(!a3_2.isActive);
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   var dest2 = profileDir.clone();
   dest2.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
   dest2.remove(true);
   dest2 = userDir.clone();
   dest2.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
   dest2.remove(true);
   dest2 = globalDir.clone();
   dest2.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
   dest2.remove(true);
 
-  startupManager();
-  shutdownManager();
+  await promiseStartupManager();
+  await promiseShutdownManager();
 
   Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_USER + AddonManager.SCOPE_SYSTEM);
 
-  writeInstallRDFForExtension(addon1, profileDir);
-  writeInstallRDFForExtension(addon2, userDir);
-  writeInstallRDFForExtension(addon3, globalDir);
+  await promiseWriteInstallRDFForExtension(addon1, profileDir);
+  await promiseWriteInstallRDFForExtension(addon2, userDir);
+  await promiseWriteInstallRDFForExtension(addon3, globalDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   let [a1_3, a2_3, a3_3] = await AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                                               "addon2@tests.mozilla.org",
                                                               "addon3@tests.mozilla.org"]);
   Assert.notEqual(a1_3, null);
   Assert.ok(!a1_3.userDisabled);
   Assert.ok(a1_3.seen);
   Assert.ok(a1_3.isActive);
@@ -897,12 +895,12 @@ async function run_test_12() {
   Assert.ok(!a2_3.seen);
   Assert.ok(!a2_3.isActive);
 
   Assert.notEqual(a3_3, null);
   Assert.ok(a3_3.userDisabled);
   Assert.ok(!a3_3.seen);
   Assert.ok(!a3_3.isActive);
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   executeSoon(end_test);
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
@@ -146,17 +146,17 @@ async function checkCompatStatus(strict,
     });
   }
 }
 
 add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   for (let addon of Object.values(ADDONS)) {
-    writeInstallRDFForExtension(addon["install.rdf"], profileDir);
+    await promiseWriteInstallRDFForExtension(addon["install.rdf"], profileDir);
   }
 
   Services.prefs.setCharPref(PREF_EM_MIN_COMPAT_APP_VERSION, "0.1");
 
   await promiseStartupManager();
 });
 
 add_task(async function test_0() {
@@ -275,17 +275,17 @@ add_task(async function setupCheckCompat
   gIsNightly = isNightlyChannel();
 
   Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
 
   Object.assign(AddonTestUtils.appInfo,
                 {version: "2.2.3", platformVersion: "2"});
 
   for (let addon of Object.values(CHECK_COMPAT_ADDONS)) {
-    writeInstallRDFForExtension(addon["install.rdf"], profileDir);
+    await promiseWriteInstallRDFForExtension(addon["install.rdf"], profileDir);
   }
   await promiseRestartManager("2.2.3");
 });
 
 // Tests that with compatibility checking enabled we see the incompatible
 // add-ons disabled
 add_task(async function test_compat_overrides_1() {
   await checkCompatOverrides(false);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js
@@ -9,17 +9,17 @@ const ID = "bootstrap1@tests.mozilla.org
 BootstrapMonitor.init();
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
 add_task(async function() {
-  startupManager();
+  await promiseStartupManager();
 
   await promiseInstallFile(do_get_addon("test_bootstrap1_1"));
 
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
 
   BootstrapMonitor.checkAddonStarted(ID);
   Assert.ok(!addon.userDisabled);
@@ -35,17 +35,17 @@ add_task(async function() {
     if (addonInstance.id == ID) {
       // Set to something that would be an invalid descriptor for this platform
       addonInstance.descriptor = AppConstants.platform == "win" ? "/foo/bar" : "C:\\foo\\bar";
     }
   }
 
   await saveJSON(jData, gExtensionsJSON.path);
 
-  startupManager();
+  await promiseStartupManager();
 
   addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
 
   BootstrapMonitor.checkAddonStarted(ID);
   Assert.ok(!addon.userDisabled);
   Assert.ok(addon.isActive);
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
@@ -8,24 +8,22 @@ ChromeUtils.import("resource://gre/modul
 this.__defineGetter__("XPIProvider", function() {
   let scope = {};
   return ChromeUtils.import("resource://gre/modules/addons/XPIProvider.jsm", scope)
                    .XPIProvider;
 });
 
 const addonId = "addon1@tests.mozilla.org";
 
-function run_test() {
+add_task(async function setup() {
   Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
-  startupManager();
-
-  run_next_test();
-}
+  await promiseStartupManager();
+});
 
 const ADDONS = [
   {
     id: "addon1@tests.mozilla.org",
     version: "1.0",
     name: "Test 1",
     bootstrap: true,
     description: "Test Description",
@@ -55,17 +53,17 @@ const UUID_PATTERN = /^\{[0-9a-f]{8}-[0-
 
 add_test(async function test_getter_and_setter() {
   // Our test add-on requires a restart.
   let listener = {
     onInstallEnded: function onInstallEnded() {
      AddonManager.removeInstallListener(listener);
      // never restart directly inside an onInstallEnded handler!
      executeSoon(async function getter_setter_install_ended() {
-      restartManager();
+      await promiseRestartManager();
 
       let addon = await AddonManager.getAddonByID(addonId);
       Assert.notEqual(addon, null);
       Assert.notEqual(addon.syncGUID, null);
       Assert.ok(UUID_PATTERN.test(addon.syncGUID));
 
       let newGUID = "foo";
 
@@ -103,27 +101,27 @@ add_test(async function test_error_on_du
 
   let listener = {
     onInstallEnded: function onInstallEnded() {
       installCount++;
 
       if (installCount == installNames.length) {
        AddonManager.removeInstallListener(listener);
        executeSoon(async function duplicate_syncguid_install_ended() {
-        restartManager();
+        await promiseRestartManager();
 
         let addons = await AddonManager.getAddonsByIDs(installIDs);
         let initialGUID = addons[1].syncGUID;
 
         try {
           addons[1].syncGUID = addons[0].syncGUID;
           do_throw("Should not get here.");
         } catch (e) {
           Assert.ok(e.message.startsWith("Addon sync GUID conflict"));
-          restartManager();
+          await promiseRestartManager();
 
           let addon = await AddonManager.getAddonByID(installIDs[1]);
           Assert.equal(initialGUID, addon.syncGUID);
           run_next_test();
         }
        });
       }
     }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js
@@ -110,17 +110,17 @@ add_task(async function() {
   // discard system addon updates
   Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "");
 
   do_get_file("data/system_addons/system_delay_ignore.xpi").copyTo(distroDir, "system_delay_ignore@tests.mozilla.org.xpi");
   do_get_file("data/system_addons/system1_1.xpi").copyTo(distroDir, "system1@tests.mozilla.org.xpi");
 
   await overrideBuiltIns({ "system": [IGNORE_ID, NORMAL_ID] });
 
-  startupManager();
+  await promiseStartupManager();
   let updateList = [
     { id: IGNORE_ID, version: "2.0", path: "system_delay_ignore_2.xpi" },
     { id: NORMAL_ID, version: "2.0", path: "system1_2.xpi" },
   ];
 
   let postponed = promiseInstallPostponed(IGNORE_ID, NORMAL_ID);
   await installSystemAddons(await buildSystemAddonUpdates(updateList, root), testserver);
   await postponed;
@@ -162,30 +162,30 @@ add_task(async function() {
   Assert.notEqual(addon_upgraded, null);
   Assert.equal(addon_upgraded.version, "2.0");
   Assert.equal(addon_upgraded.name, "System Add-on 1");
   Assert.ok(addon_upgraded.isCompatible);
   Assert.ok(!addon_upgraded.appDisabled);
   Assert.ok(addon_upgraded.isActive);
   Assert.equal(addon_upgraded.type, "extension");
 
-  await shutdownManager();
+  await await promiseShutdownManager();
 });
 
 // add-on registers upgrade listener, and allows update.
 add_task(async function() {
   // discard system addon updates
   Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "");
 
   do_get_file("data/system_addons/system_delay_complete.xpi").copyTo(distroDir, "system_delay_complete@tests.mozilla.org.xpi");
   do_get_file("data/system_addons/system1_1.xpi").copyTo(distroDir, "system1@tests.mozilla.org.xpi");
 
   await overrideBuiltIns({ "system": [COMPLETE_ID, NORMAL_ID] });
 
-  startupManager();
+  await promiseStartupManager();
 
   let updateList = [
     { id: COMPLETE_ID, version: "2.0", path: "system_delay_complete_2.xpi" },
     { id: NORMAL_ID, version: "2.0", path: "system1_2.xpi" },
   ];
 
   // initial state
   let addon_allowed = await promiseAddonByID(COMPLETE_ID);
@@ -248,30 +248,30 @@ add_task(async function() {
   Assert.notEqual(addon_upgraded, null);
   Assert.equal(addon_upgraded.version, "2.0");
   Assert.equal(addon_upgraded.name, "System Add-on 1");
   Assert.ok(addon_upgraded.isCompatible);
   Assert.ok(!addon_upgraded.appDisabled);
   Assert.ok(addon_upgraded.isActive);
   Assert.equal(addon_upgraded.type, "extension");
 
-  await shutdownManager();
+  await await promiseShutdownManager();
 });
 
 // add-on registers upgrade listener, initially defers update then allows upgrade
 add_task(async function() {
   // discard system addon updates
   Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "");
 
   do_get_file("data/system_addons/system_delay_defer.xpi").copyTo(distroDir, "system_delay_defer@tests.mozilla.org.xpi");
   do_get_file("data/system_addons/system1_1.xpi").copyTo(distroDir, "system1@tests.mozilla.org.xpi");
 
   await overrideBuiltIns({ "system": [DEFER_ID, NORMAL_ID] });
 
-  startupManager();
+  await promiseStartupManager();
 
   let updateList = [
     { id: DEFER_ID, version: "2.0", path: "system_delay_defer_2.xpi" },
     { id: NORMAL_ID, version: "2.0", path: "system1_2.xpi" },
   ];
 
   let postponed = promiseInstallPostponed(DEFER_ID, NORMAL_ID);
   await installSystemAddons(await buildSystemAddonUpdates(updateList, root), testserver);
@@ -339,30 +339,30 @@ add_task(async function() {
   Assert.notEqual(addon_upgraded, null);
   Assert.equal(addon_upgraded.version, "2.0");
   Assert.equal(addon_upgraded.name, "System Add-on 1");
   Assert.ok(addon_upgraded.isCompatible);
   Assert.ok(!addon_upgraded.appDisabled);
   Assert.ok(addon_upgraded.isActive);
   Assert.equal(addon_upgraded.type, "extension");
 
-  await shutdownManager();
+  await await promiseShutdownManager();
 });
 
 // multiple add-ons registers upgrade listeners, initially defers then each unblock in turn.
 add_task(async function() {
   // discard system addon updates.
   Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "");
 
   do_get_file("data/system_addons/system_delay_defer.xpi").copyTo(distroDir, "system_delay_defer@tests.mozilla.org.xpi");
   do_get_file("data/system_addons/system_delay_defer_also.xpi").copyTo(distroDir, "system_delay_defer_also@tests.mozilla.org.xpi");
 
   await overrideBuiltIns({ "system": [DEFER_ID, DEFER_ALSO_ID] });
 
-  startupManager();
+  await promiseStartupManager();
 
   let updateList = [
     { id: DEFER_ID, version: "2.0", path: "system_delay_defer_2.xpi" },
     { id: DEFER_ALSO_ID, version: "2.0", path: "system_delay_defer_also_2.xpi" },
   ];
 
   let postponed = promiseInstallPostponed(DEFER_ID, DEFER_ALSO_ID);
   await installSystemAddons(await buildSystemAddonUpdates(updateList, root), testserver);
@@ -451,10 +451,10 @@ add_task(async function() {
   Assert.notEqual(addon_upgraded, null);
   Assert.equal(addon_upgraded.version, "2.0");
   Assert.equal(addon_upgraded.name, "System Test Delay Update Defer Also");
   Assert.ok(addon_upgraded.isCompatible);
   Assert.ok(!addon_upgraded.appDisabled);
   Assert.ok(addon_upgraded.isActive);
   Assert.equal(addon_upgraded.type, "extension");
 
-  await shutdownManager();
+  await await promiseShutdownManager();
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_repository.js
@@ -24,17 +24,17 @@ add_task(async function test_app_addons(
   Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES, `http://localhost:${gServer.identity.primaryPort}/get?%IDS%`);
 
   gServer.registerPathHandler("/get", (request, response) => {
     do_throw("Unexpected request to server.");
   });
 
   awaitPromise(overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org"] }));
 
-  startupManager();
+  await promiseStartupManager();
 
   await AddonRepository.cacheAddons(["system1@tests.mozilla.org",
                                      "system2@tests.mozilla.org",
                                      "system3@tests.mozilla.org"]);
 
   let cached = await AddonRepository.getCachedAddonByID("system1@tests.mozilla.org");
   Assert.equal(cached, null);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
@@ -91,17 +91,17 @@ async function check_installed(condition
         BootstrapMonitor.checkAddonNotInstalled(id);
     }
   }
 }
 
 // Test with a missing features directory
 add_task(async function test_missing_app_dir() {
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: null },
       { isUpgrade: false, version: null },
       { isUpgrade: false, version: null },
   ];
 
   await check_installed(conditions);
@@ -111,17 +111,17 @@ add_task(async function test_missing_app
   await promiseShutdownManager();
 });
 
 // Add some features in a new version
 add_task(async function test_new_version() {
   gAppInfo.version = "1";
   distroDir.leafName = "app1";
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: null },
   ];
 
   await check_installed(conditions);
@@ -131,17 +131,17 @@ add_task(async function test_new_version
   await promiseShutdownManager();
 });
 
 // Another new version swaps one feature and upgrades another
 add_task(async function test_upgrade() {
   gAppInfo.version = "2";
   distroDir.leafName = "app2";
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "2.0" },
       { isUpgrade: false, version: null },
       { isUpgrade: false, version: "1.0" },
   ];
 
   await check_installed(conditions);
@@ -151,17 +151,17 @@ add_task(async function test_upgrade() {
   await promiseShutdownManager();
 });
 
 // Downgrade
 add_task(async function test_downgrade() {
   gAppInfo.version = "1";
   distroDir.leafName = "app1";
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: null },
   ];
 
   await check_installed(conditions);
@@ -195,17 +195,17 @@ add_task(async function test_updated() {
       "system3@tests.mozilla.org": {
         version: "2.0"
       },
     }
   };
   Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, JSON.stringify(addonSet));
 
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: true, version: "2.0" },
       { isUpgrade: true, version: "2.0" },
   ];
 
   await check_installed(conditions);
@@ -213,34 +213,34 @@ add_task(async function test_updated() {
   await promiseShutdownManager();
 });
 
 // Entering safe mode should disable the updated system add-ons and use the
 // default system add-ons
 add_task(async function safe_mode_disabled() {
   gAppInfo.inSafeMode = true;
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: null },
   ];
 
   await check_installed(conditions);
 
   await promiseShutdownManager();
 });
 
 // Leaving safe mode should re-enable the updated system add-ons
 add_task(async function normal_mode_enabled() {
   gAppInfo.inSafeMode = false;
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: true, version: "2.0" },
       { isUpgrade: true, version: "2.0" },
   ];
 
   await check_installed(conditions);
@@ -250,17 +250,17 @@ add_task(async function normal_mode_enab
 
 // An additional add-on in the directory should be ignored
 add_task(async function test_skips_additional() {
   // Copy in the system add-ons
   let file = do_get_file("data/system_addons/system4_1.xpi");
   file.copyTo(updatesDir, "system4@tests.mozilla.org.xpi");
 
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: true, version: "2.0" },
       { isUpgrade: true, version: "2.0" },
   ];
 
   await check_installed(conditions);
@@ -271,17 +271,17 @@ add_task(async function test_skips_addit
 // Missing add-on should revert to the default set
 add_task(async function test_revert() {
   manuallyUninstall(updatesDir, "system2@tests.mozilla.org");
 
   // With the add-on physically gone from disk we won't see uninstall events
   BootstrapMonitor.clear("system2@tests.mozilla.org");
 
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   // With system add-on 2 gone the updated set is now invalid so it reverts to
   // the default set which is system add-ons 1 and 2.
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: null },
   ];
@@ -292,17 +292,17 @@ add_task(async function test_revert() {
 });
 
 // Putting it back will make the set work again
 add_task(async function test_reuse() {
   let file = do_get_file("data/system_addons/system2_2.xpi");
   file.copyTo(updatesDir, "system2@tests.mozilla.org.xpi");
 
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: true, version: "2.0" },
       { isUpgrade: true, version: "2.0" },
   ];
 
   await check_installed(conditions);
@@ -310,17 +310,17 @@ add_task(async function test_reuse() {
   await promiseShutdownManager();
 });
 
 // Making the pref corrupt should revert to the default set
 add_task(async function test_corrupt_pref() {
   Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "foo");
 
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: null },
   ];
 
   await check_installed(conditions);
@@ -347,17 +347,17 @@ add_task(async function test_bad_profile
       "system3@tests.mozilla.org": {
         version: "1.0"
       },
     }
   };
   Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, JSON.stringify(addonSet));
 
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: null },
   ];
 
   await check_installed(conditions);
@@ -365,17 +365,17 @@ add_task(async function test_bad_profile
   await promiseShutdownManager();
 });
 
 // Switching to app defaults that contain a bad certificate should still work
 add_task(async function test_bad_app_cert() {
   gAppInfo.version = "3";
   distroDir.leafName = "app3";
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   // Since we updated the app version, the system addon set should be reset as well.
   let addonSet = Services.prefs.getCharPref(PREF_SYSTEM_ADDON_SET);
   Assert.equal(addonSet, `{"schema":1,"addons":{}}`);
 
   // Add-on will still be present
   let addon = await promiseAddonByID("system1@tests.mozilla.org");
   Assert.notEqual(addon, null);
@@ -416,17 +416,17 @@ add_task(async function test_updated_bad
       "system_failed_update@tests.mozilla.org": {
         version: "1.0"
       },
     }
   };
   Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, JSON.stringify(addonSet));
 
   await overrideBuiltIns({ "system": ["system1@tests.mozilla.org", "system2@tests.mozilla.org", "system3@tests.mozilla.org", "system5@tests.mozilla.org"] });
-  startupManager();
+  await promiseStartupManager();
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
   ];
 
   await check_installed(conditions);
 
   await promiseShutdownManager();
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_blank.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_blank.js
@@ -103,17 +103,17 @@ const TESTS = {
   blank: {
     updateList: null,
   }
 };
 
 add_task(async function setup() {
   // Initialise the profile
   awaitPromise(overrideBuiltIns({ "system": [] }));
-  startupManager();
+  await promiseStartupManager();
   await promiseShutdownManager();
 });
 
 add_task(async function() {
   for (let setupName of Object.keys(TEST_CONDITIONS)) {
     for (let testName of Object.keys(TESTS)) {
         info("Running test " + setupName + " " + testName);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_checkSizeHash.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_checkSizeHash.js
@@ -137,17 +137,17 @@ const TESTS = {
       ]
     }
   }
 };
 
 add_task(async function setup() {
   // Initialise the profile
   awaitPromise(overrideBuiltIns({ "system": [] }));
-  startupManager();
+  await promiseStartupManager();
   await promiseShutdownManager();
 });
 
 add_task(async function() {
   for (let setupName of Object.keys(TEST_CONDITIONS)) {
     for (let testName of Object.keys(TESTS)) {
         info("Running test " + setupName + " " + testName);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_fail.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_fail.js
@@ -161,17 +161,17 @@ const TESTS = {
       { id: "system3@tests.mozilla.org", version: "1.0", path: "system3_1.xpi" }
     ],
   }
 };
 
 add_task(async function setup() {
   // Initialise the profile
   await overrideBuiltIns({ "system": [] });
-  startupManager();
+  await promiseStartupManager();
   await promiseShutdownManager();
 });
 
 add_task(async function() {
   for (let setupName of Object.keys(TEST_CONDITIONS)) {
     for (let testName of Object.keys(TESTS)) {
         info("Running test " + setupName + " " + testName);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_newset.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_newset.js
@@ -136,17 +136,17 @@ const TESTS = {
       ]
     }
   }
 };
 
 add_task(async function setup() {
   // Initialise the profile
   awaitPromise(overrideBuiltIns({ "system": [] }));
-  startupManager();
+  await promiseStartupManager();
   await promiseShutdownManager();
 });
 
 add_task(async function() {
   for (let setupName of Object.keys(TEST_CONDITIONS)) {
     for (let testName of Object.keys(TESTS)) {
         info("Running test " + setupName + " " + testName);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_overlapping.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_overlapping.js
@@ -138,17 +138,17 @@ const TESTS = {
       ]
     }
   }
 };
 
 add_task(async function setup() {
   // Initialise the profile
   awaitPromise(overrideBuiltIns({ "system": [] }));
-  startupManager();
+  await promiseStartupManager();
   await promiseShutdownManager();
 });
 
 add_task(async function() {
   for (let setupName of Object.keys(TEST_CONDITIONS)) {
     for (let testName of Object.keys(TESTS)) {
         info("Running test " + setupName + " " + testName);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_upgrades.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_upgrades.js
@@ -136,17 +136,17 @@ const TESTS = {
       ]
     }
   }
 };
 
 add_task(async function setup() {
   // Initialise the profile
   awaitPromise(overrideBuiltIns({ "system": [] }));
-  startupManager();
+  await promiseStartupManager();
   await promiseShutdownManager();
 });
 
 add_task(async function() {
   for (let setupName of Object.keys(TEST_CONDITIONS)) {
     for (let testName of Object.keys(TESTS)) {
         info("Running test " + setupName + " " + testName);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
@@ -360,17 +360,17 @@ add_task(async function test_samefile() 
 // Uninstall it and make sure the existing add-on comes back.
 add_task(async function() {
   await promiseInstallAllFiles([do_get_addon("test_bootstrap1_1")], true);
 
   BootstrapMonitor.checkAddonInstalled(ID, "1.0");
   BootstrapMonitor.checkAddonStarted(ID, "1.0");
 
   let tempdir = gTmpD.clone();
-  writeInstallRDFToDir({
+  await promiseWriteInstallRDFToDir({
     id: ID,
     version: "2.0",
     bootstrap: true,
     unpack: true,
     targetApplications: [{
           id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
@@ -458,29 +458,28 @@ add_task(async function() {
   await promiseRestartManager();
 });
 
 // Install a temporary add-on as a version upgrade over the top of an
 // existing temporary add-on.
 add_task(async function() {
   const tempdir = gTmpD.clone();
 
-  writeInstallRDFToDir(sampleRDFManifest, tempdir,
-                       "bootstrap1@tests.mozilla.org", "bootstrap.js");
+  await promiseWriteInstallRDFToDir(sampleRDFManifest, tempdir, "bootstrap1@tests.mozilla.org", "bootstrap.js");
 
   const unpackedAddon = tempdir.clone();
   unpackedAddon.append(ID);
   do_get_file("data/test_temporary/bootstrap.js")
     .copyTo(unpackedAddon, "bootstrap.js");
 
   await AddonManager.installTemporaryAddon(unpackedAddon);
 
   // Increment the version number, re-install it, and make sure it
   // gets marked as an upgrade.
-  writeInstallRDFToDir(Object.assign({}, sampleRDFManifest, {
+  await promiseWriteInstallRDFToDir(Object.assign({}, sampleRDFManifest, {
     version: "2.0"
   }), tempdir, "bootstrap1@tests.mozilla.org");
 
   const onShutdown = waitForBootstrapEvent("shutdown", ID);
   const onUninstall = waitForBootstrapEvent("uninstall", ID);
   const onInstall = waitForBootstrapEvent("install", ID);
   const onStartup = waitForBootstrapEvent("startup", ID);
   await AddonManager.installTemporaryAddon(unpackedAddon);
@@ -510,29 +509,28 @@ add_task(async function() {
   await promiseRestartManager();
 });
 
 // Install a temporary add-on as a version downgrade over the top of an
 // existing temporary add-on.
 add_task(async function() {
   const tempdir = gTmpD.clone();
 
-  writeInstallRDFToDir(sampleRDFManifest, tempdir,
-                       "bootstrap1@tests.mozilla.org", "bootstrap.js");
+  await promiseWriteInstallRDFToDir(sampleRDFManifest, tempdir, "bootstrap1@tests.mozilla.org", "bootstrap.js");
 
   const unpackedAddon = tempdir.clone();
   unpackedAddon.append(ID);
   do_get_file("data/test_temporary/bootstrap.js")
     .copyTo(unpackedAddon, "bootstrap.js");
 
   await AddonManager.installTemporaryAddon(unpackedAddon);
 
   // Decrement the version number, re-install, and make sure
   // it gets marked as a downgrade.
-  writeInstallRDFToDir(Object.assign({}, sampleRDFManifest, {
+  await promiseWriteInstallRDFToDir(Object.assign({}, sampleRDFManifest, {
     version: "0.8"
   }), tempdir, "bootstrap1@tests.mozilla.org");
 
   const onShutdown = waitForBootstrapEvent("shutdown", ID);
   const onUninstall = waitForBootstrapEvent("uninstall", ID);
   const onInstall = waitForBootstrapEvent("install", ID);
   const onStartup = waitForBootstrapEvent("startup", ID);
   await AddonManager.installTemporaryAddon(unpackedAddon);
@@ -560,18 +558,17 @@ add_task(async function() {
   await promiseRestartManager();
 });
 
 // Installing a temporary add-on over an existing add-on with the same
 // version number should be installed as an upgrade.
 add_task(async function() {
   const tempdir = gTmpD.clone();
 
-  writeInstallRDFToDir(sampleRDFManifest, tempdir,
-                       "bootstrap1@tests.mozilla.org", "bootstrap.js");
+  await promiseWriteInstallRDFToDir(sampleRDFManifest, tempdir, "bootstrap1@tests.mozilla.org", "bootstrap.js");
 
   const unpackedAddon = tempdir.clone();
   unpackedAddon.append(ID);
   do_get_file("data/test_temporary/bootstrap.js")
     .copyTo(unpackedAddon, "bootstrap.js");
 
   const onInitialInstall = waitForBootstrapEvent("install", ID);
   const onInitialStartup = waitForBootstrapEvent("startup", ID);
@@ -629,17 +626,17 @@ add_task(async function() {
   let addon = await promiseAddonByID(ID);
 
   addon.userDisabled = true;
 
   BootstrapMonitor.checkAddonInstalled(ID, "1.0");
   BootstrapMonitor.checkAddonNotStarted(ID);
 
   let tempdir = gTmpD.clone();
-  writeInstallRDFToDir({
+  await promiseWriteInstallRDFToDir({
     id: ID,
     version: "2.0",
     bootstrap: true,
     unpack: true,
     targetApplications: [{
           id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
--- a/toolkit/mozapps/extensions/test/xpcshell/test_types.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_types.js
@@ -1,18 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // This verifies that custom types can be defined and undefined
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
-function run_test() {
-  startupManager();
+add_task(async function setup() {
+  await promiseStartupManager();
 
   Assert.equal(false, "test" in AddonManager.addonTypes);
   let types = AddonManager.addonTypes;
 
   // The dumbest provider possible
   var provider = {
   };
 
@@ -57,9 +57,9 @@ function run_test() {
 
   AddonManagerPrivate.unregisterProvider(provider);
 
   Assert.equal(expectedRemove, null);
 
   Assert.equal(false, "test" in AddonManager.addonTypes);
   // The cached reference to addonTypes is live
   Assert.equal(false, "test" in types);
-}
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js
@@ -41,24 +41,22 @@ function getUninstallReason(id) {
 }
 
 function getShutdownNewVersion(id) {
   let info = BootstrapMonitor.stopped.get(id);
   return info ? info.data.newVersion : undefined;
 }
 
 // Sets up the profile by installing an add-on.
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
-  startupManager();
+  await promiseStartupManager();
   registerCleanupFunction(promiseShutdownManager);
-
-  run_next_test();
-}
+});
 
 // Tests that an enabled restartless add-on can be uninstalled and goes away
 // when the uninstall is committed
 add_task(async function uninstallRestartless() {
   prepare_test({
     "undouninstall1@tests.mozilla.org": [
       ["onInstalling", false],
       "onInstalled"
@@ -169,22 +167,22 @@ add_task(async function cancelUninstallO
 
   BootstrapMonitor.checkAddonInstalled(ID, "1.0");
   BootstrapMonitor.checkAddonStarted(ID, "1.0");
   Assert.equal(getStartupReason(ID), ADDON_INSTALL);
   Assert.equal(a1.pendingOperations, AddonManager.PENDING_NONE);
   Assert.ok(a1.isActive);
   Assert.ok(!a1.userDisabled);
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   Assert.equal(getShutdownReason(ID), APP_SHUTDOWN);
   Assert.equal(getShutdownNewVersion(ID), undefined);
 
-  startupManager();
+  await promiseStartupManager();
 
   a1 = await promiseAddonByID("undouninstall1@tests.mozilla.org");
 
   Assert.notEqual(a1, null);
   BootstrapMonitor.checkAddonStarted(ID, "1.0");
   Assert.equal(getStartupReason(ID), APP_STARTUP);
   Assert.equal(a1.pendingOperations, AddonManager.PENDING_NONE);
   Assert.ok(a1.isActive);
@@ -248,21 +246,25 @@ add_task(async function reinstallAddonAw
   BootstrapMonitor.checkAddonStarted(ID, "1.0");
   Assert.equal(getUninstallReason(ID), ADDON_DOWNGRADE);
   Assert.equal(getInstallReason(ID), ADDON_DOWNGRADE);
   Assert.equal(getStartupReason(ID), ADDON_DOWNGRADE);
   Assert.equal(a1.pendingOperations, AddonManager.PENDING_NONE);
   Assert.ok(a1.isActive);
   Assert.ok(!a1.userDisabled);
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   Assert.equal(getShutdownReason(ID), APP_SHUTDOWN);
 
+<<<<<<< dest
   startupManager();
+=======
+  await promiseStartupManager(false);
+>>>>>>> source
 
   a1 = await promiseAddonByID("undouninstall1@tests.mozilla.org");
 
   Assert.notEqual(a1, null);
   BootstrapMonitor.checkAddonStarted(ID, "1.0");
   Assert.equal(getStartupReason(ID), APP_STARTUP);
   Assert.equal(a1.pendingOperations, AddonManager.PENDING_NONE);
   Assert.ok(a1.isActive);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js
@@ -51,31 +51,33 @@ function dataHandler(aRequest, aResponse
 }
 var testserver = new HttpServer();
 testserver.registerDirectory("/addons/", do_get_file("addons"));
 testserver.registerPathHandler("/data/test_update.json", dataHandler);
 testserver.start(-1);
 gPort = testserver.identity.primaryPort;
 
 // Set up an add-on for update check
-writeInstallRDFForExtension({
-  id: "addon1@tests.mozilla.org",
-  version: "1.0",
-  bootstrap: true,
-  updateURL: "http://localhost:" + gPort + "/data/test_update.json",
-  targetApplications: [{
-    id: "xpcshell@tests.mozilla.org",
-    minVersion: "1",
-    maxVersion: "1"
-  }],
-  name: "Test Addon 1",
-}, profileDir);
+add_task(async function setup() {
+  await promiseWriteInstallRDFForExtension({
+    id: "addon1@tests.mozilla.org",
+    version: "1.0",
+    bootstrap: true,
+    updateURL: "http://localhost:" + gPort + "/data/test_update.json",
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "1",
+      maxVersion: "1"
+    }],
+    name: "Test Addon 1",
+  }, profileDir);
+});
 
 add_task(async function cancel_during_check() {
-  startupManager();
+  await promiseStartupManager();
 
   let a1 = await promiseAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(a1, null);
 
   let listener = makeCancelListener();
   a1.findUpdates(listener, AddonManager.UPDATE_WHEN_USER_REQUESTED);
 
   // Wait for the http request to arrive
@@ -111,17 +113,17 @@ add_task(async function shutdown_during_
   Assert.notEqual(a1, null);
 
   let listener = makeCancelListener();
   a1.findUpdates(listener, AddonManager.UPDATE_WHEN_USER_REQUESTED);
 
   // Wait for the http request to arrive
   let [/* request */, response] = await httpReceived.promise;
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   let updateResult = await listener.promise;
   Assert.equal(AddonManager.UPDATE_STATUS_CANCELLED, updateResult);
 
   // Now complete the HTTP request
   let file = do_get_cwd();
   file.append("data");
   file.append("test_update.json");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
@@ -11,74 +11,74 @@ Services.prefs.setBoolPref(PREF_EM_CHECK
 
 var testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
 testserver.registerDirectory("/data/", do_get_file("data"));
 testserver.registerDirectory("/addons/", do_get_file("addons"));
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
-function run_test() {
+async function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "compatmode-normal@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     updateURL: "http://example.com/data/test_updatecompatmode_%COMPATIBILITY_MODE%.json",
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test Addon - normal"
   }, profileDir);
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "compatmode-strict@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     updateURL: "http://example.com/data/test_updatecompatmode_%COMPATIBILITY_MODE%.json",
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test Addon - strict"
   }, profileDir);
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "compatmode-strict-optin@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     updateURL: "http://example.com/data/test_updatecompatmode_%COMPATIBILITY_MODE%.json",
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test Addon - strict opt-in",
     strictCompatibility: true
   }, profileDir);
 
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "compatmode-ignore@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     updateURL: "http://example.com/data/test_updatecompatmode_%COMPATIBILITY_MODE%.json",
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test Addon - ignore",
   }, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
   run_test_1();
 }
 
 function end_test() {
   do_test_finished();
 }
 
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js
@@ -21,30 +21,30 @@ profileDir.append("extensions");
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
 
 const updateFile = "test_update.json";
 const appId = "toolkit@mozilla.org";
 
 // Test that the update check correctly observes the
 // extensions.strictCompatibility pref and compatibility overrides.
-add_test(function() {
-  writeInstallRDFForExtension({
+add_test(async function() {
+  await promiseWriteInstallRDFForExtension({
     id: "addon9@tests.mozilla.org",
     version: "1.0",
     updateURL: "http://example.com/data/" + updateFile,
     targetApplications: [{
       id: appId,
       minVersion: "0.1",
       maxVersion: "0.2"
     }],
     name: "Test Addon 9",
   }, profileDir);
 
-  restartManager();
+  await promiseRestartManager();
 
   AddonManager.addInstallListener({
     onNewInstall(aInstall) {
       if (aInstall.existingAddon.id != "addon9@tests.mozilla.org")
         do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
       Assert.equal(aInstall.version, "4.0");
     },
     onDownloadFailed(aInstall) {
@@ -59,29 +59,29 @@ add_test(function() {
   Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
 
   AddonManagerInternal.backgroundUpdateCheck();
 });
 
 // Test that the update check correctly observes when an addon opts-in to
 // strict compatibility checking.
 add_test(async function() {
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "addon11@tests.mozilla.org",
     version: "1.0",
     updateURL: "http://example.com/data/" + updateFile,
     targetApplications: [{
       id: appId,
       minVersion: "0.1",
       maxVersion: "0.2"
     }],
     name: "Test Addon 11",
   }, profileDir);
 
-  restartManager();
+  await promiseRestartManager();
 
   let a11 = await AddonManager.getAddonByID("addon11@tests.mozilla.org");
   Assert.notEqual(a11, null);
 
   a11.findUpdates({
     onCompatibilityUpdateAvailable() {
       do_throw("Should not have seen compatibility information");
     },
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js
@@ -119,24 +119,22 @@ var checkUpdates = async function(aData,
 
   let updates = await promiseFindAddonUpdates(addon, aReason);
   updates.addon = addon;
 
   return updates;
 };
 
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "42.0", "42.0");
 
-  startupManager();
+  await promiseStartupManager();
   registerCleanupFunction(promiseShutdownManager);
-
-  run_next_test();
-}
+});
 
 
 // Check that compatibility updates are applied.
 add_task(async function checkUpdateMetadata() {
   let update = await checkUpdates({
     addon: {
       manifest: {
         version: "1.0",
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
@@ -30,21 +30,20 @@ function promiseInstallUpdate(install) {
   });
 }
 
 // Create and configure the HTTP server.
 let testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
 testserver.registerDirectory("/data/", do_get_file("data"));
 testserver.registerDirectory("/addons/", do_get_file("addons"));
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-  startupManager();
-  run_next_test();
-}
+  await promiseStartupManager();
+});
 
 // Verify that an update to an add-on with a new ID fails
 add_task(async function test_update_new_id() {
   await promiseInstallFile(do_get_addon("test_updateid1"));
 
   let addon = await promiseAddonByID("addon1@tests.mozilla.org");
   Assert.notEqual(addon, null);
   Assert.equal(addon.version, "1.0");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js
@@ -16,81 +16,81 @@ const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
 const globalDir = Services.dirsvc.get("XREAddonAppDir", Ci.nsIFile);
 globalDir.append("extensions");
 
 var gGlobalExisted = globalDir.exists();
 var gInstallTime = Date.now();
 
-function run_test() {
+async function run_test() {
+  do_test_pending();
+
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   // Will be compatible in the first version and incompatible in subsequent versions
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "addon1@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test Addon 1",
     targetPlatforms: [
       "XPCShell",
       "WINNT_x86",
     ]
   }, profileDir);
 
   // Works in all tested versions
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "addon2@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "2"
     }],
     name: "Test Addon 2",
     targetPlatforms: [
       "XPCShell_noarch-spidermonkey"
     ]
   }, profileDir);
 
   // Will be disabled in the first version and enabled in the second.
-  writeInstallRDFForExtension({
+  await promiseWriteInstallRDFForExtension({
     id: "addon3@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "2",
       maxVersion: "2"
     }],
     name: "Test Addon 3",
   }, profileDir);
 
   // Will be compatible in both versions but will change version in between
-  var dest = writeInstallRDFForExtension({
+  var dest = await promiseWriteInstallRDFForExtension({
     id: "addon4@tests.mozilla.org",
     version: "1.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "1"
     }],
     name: "Test Addon 4",
   }, globalDir);
   setExtensionModifiedTime(dest, gInstallTime);
 
-  do_test_pending();
-
   run_test_1();
 }
 
 function end_test() {
   if (!gGlobalExisted) {
     globalDir.remove(true);
   } else {
     globalDir.append(do_get_expected_addon_name("addon4@tests.mozilla.org"));
@@ -121,17 +121,17 @@ async function run_test_1() {
   Assert.equal(a4.version, "1.0");
 
   executeSoon(run_test_2);
 }
 
 // Test that upgrading the application doesn't disable now incompatible add-ons
 async function run_test_2() {
   // Upgrade the extension
-  var dest = writeInstallRDFForExtension({
+  var dest = await promiseWriteInstallRDFForExtension({
     id: "addon4@tests.mozilla.org",
     version: "2.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "2",
       maxVersion: "2"
     }],
@@ -158,33 +158,33 @@ async function run_test_2() {
   Assert.equal(a4.version, "2.0");
 
   executeSoon(run_test_3);
 }
 
 // Test that nothing changes when only the build ID changes.
 async function run_test_3() {
   // Upgrade the extension
-  var dest = writeInstallRDFForExtension({
+  var dest = await promiseWriteInstallRDFForExtension({
     id: "addon4@tests.mozilla.org",
     version: "3.0",
     bootstrap: true,
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "3",
       maxVersion: "3"
     }],
     name: "Test Addon 4",
   }, globalDir);
   setExtensionModifiedTime(dest, gInstallTime);
 
   // Simulates a simple Build ID change, the platform deletes extensions.ini
   // whenever the application is changed.
   gAddonStartup.remove(true);
-  restartManager();
+  await promiseRestartManager();
 
   let [a1, a2, a3, a4] = await AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                                             "addon2@tests.mozilla.org",
                                                             "addon3@tests.mozilla.org",
                                                             "addon4@tests.mozilla.org"]);
   Assert.notEqual(a1, null);
   Assert.ok(isExtensionInBootstrappedList(profileDir, a1.id));
 
@@ -193,12 +193,12 @@ async function run_test_3() {
 
   Assert.notEqual(a3, null);
   Assert.ok(isExtensionInBootstrappedList(profileDir, a3.id));
 
   Assert.notEqual(a4, null);
   Assert.ok(isExtensionInBootstrappedList(globalDir, a4.id));
   Assert.equal(a4.version, "2.0");
 
-  shutdownManager();
+  await promiseShutdownManager();
 
   end_test();
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
@@ -51,17 +51,17 @@ add_task(async function() {
   Assert.equal(addon.iconURL, uri + "icon48.png");
   Assert.equal(addon.icon64URL, uri + "icon64.png");
 
   // Should persist through a restart
   await promiseShutdownManager();
 
   equal(GlobalManager.extensionMap.size, 0);
 
-  startupManager();
+  await promiseStartupManager();
   await promiseWebExtensionStartup();
 
   equal(GlobalManager.extensionMap.size, 1);
   ok(GlobalManager.extensionMap.has(ID));
 
   addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.equal(addon.version, "1.0");
@@ -107,17 +107,17 @@ add_task(async function() {
     manifest_version: 2,
     applications: {
       gecko: {
         id: ID
       }
     }
   }, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
   await promiseWebExtensionStartup();
 
   let addon = await promiseAddonByID(ID);
   Assert.notEqual(addon, null);
   Assert.equal(addon.version, "1.0");
   Assert.equal(addon.name, "Web Extension Name");
   Assert.ok(addon.isCompatible);
   Assert.ok(!addon.appDisabled);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
@@ -5,17 +5,17 @@ let profileDir;
 add_task(async function setup() {
   profileDir = gProfD.clone();
   profileDir.append("extensions");
 
   if (!profileDir.exists())
     profileDir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-  startupManager();
+  await promiseStartupManager();
 });
 
 const IMPLICIT_ID_XPI = "data/webext-implicit-id.xpi";
 const IMPLICIT_ID_ID = "webext_implicit_id@tests.mozilla.org";
 
 // webext-implicit-id.xpi has a minimal manifest with no
 // applications or browser_specific_settings, so its id comes
 // from its signature, which should be the ID constant defined below.
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install_syntax_error.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install_syntax_error.js
@@ -1,10 +1,15 @@
 const ADDON_ID = "webext-test@tests.mozilla.org";
 
+add_task(async function setup() {
+  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
+  await promiseStartupManager();
+});
+
 add_task(async function install_xpi() {
 
   // Data for WebExtension with syntax error
   let xpi1 = Extension.generateXPI({
     files: {
       "manifest.json": String.raw`{
         // This is a manifest. Intentional syntax error in next line.
         "manifest_version: 2,
@@ -35,15 +40,8 @@ add_task(async function install_xpi() {
   // Replace xpi1 with xpi2 to have the same filename to reproduce install error
   xpi2.moveTo(xpi1.parent, xpi1.leafName);
 
   let install2 = await AddonManager.getInstallForFile(xpi2);
   Assert.notEqual(install2.error, AddonManager.ERROR_CORRUPT_FILE);
 
   xpi1.remove(false);
 });
-
-function run_test() {
-  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-  startupManager();
-
-  run_next_test();
-}
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js
@@ -1,16 +1,16 @@
 
 let profileDir;
 add_task(async function setup() {
   profileDir = gProfD.clone();
   profileDir.append("extensions");
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-  startupManager();
+  await promiseStartupManager();
 });
 
 // When installing an unpacked addon we derive the ID from the
 // directory name.  Make sure that if the directory name is not a valid
 // addon ID that we reject it.
 add_task(async function test_bad_unpacked_path() {
   let MANIFEST_ID = "webext_bad_path@tests.mozilla.org";
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_theme.js
@@ -34,17 +34,17 @@ add_task(async function setup_to_default
     theme: { images: { headerURL: "example.png" } },
     applications: {
       gecko: {
         id: THEME_IDS[0]
       }
     }
   }, profileDir);
 
-  startupManager();
+  await promiseStartupManager();
 
   // We can add an LWT only after the Addon Manager was started.
   LightweightThemeManager.currentTheme = {
     id: THEME_IDS[1].substr(0, THEME_IDS[1].indexOf("@")),
     version: "1",
     name: "Bling",
     description: "SO MUCH BLING!",
     author: "Pixel Pusher",