Bug 1454202: Part 5b-c - Remove interstitial callback argument from getInstall* APIs. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Sun, 15 Apr 2018 14:22:55 -0700
changeset 468496 81d9e69a3539603114d1b97f9700c14f45affd49
parent 468495 ebacf44a86dc27644717e72a2a302d586d5d81a1
child 468497 894d7e5286e1cd81586232dcd18c2a3300f000d5
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1454202
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1454202: Part 5b-c - Remove interstitial callback argument from getInstall* APIs. r=aswan *** Bug 1454202: Part 5b - Remove interstitial callback argument from getInstall* APIs. r=aswan MozReview-Commit-ID: ATKWozPZF4d *** Bug 1454202: Part 5c - Update callers for new getInstall* signature. r=aswan MozReview-Commit-ID: FWzZ2dxZOGs
browser/base/content/browser.js
browser/base/content/test/general/browser_bug592338.js
browser/base/content/test/webextensions/head.js
browser/components/enterprisepolicies/Policies.jsm
devtools/client/webide/modules/addons.js
services/sync/modules/addonutils.js
toolkit/components/normandy/lib/Addons.jsm
toolkit/mozapps/extensions/AddonManager.jsm
toolkit/mozapps/extensions/addonManager.js
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/AddonManagerTesting.jsm
toolkit/mozapps/extensions/test/browser/browser_bug596336.js
toolkit/mozapps/extensions/test/browser/browser_installssl.js
toolkit/mozapps/extensions/test/browser/browser_update.js
toolkit/mozapps/extensions/test/browser/head.js
toolkit/mozapps/extensions/test/mochitest/test_bug687194.html
toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js
toolkit/mozapps/extensions/test/xpcshell/test_error.js
toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
toolkit/mozapps/extensions/test/xpcshell/test_install.js
toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js
toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
toolkit/mozapps/extensions/test/xpcshell/test_update.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -969,17 +969,17 @@ function serializeInputStream(aStream) {
  */
 function handleUriInChrome(aBrowser, aUri) {
   if (aUri.scheme == "file") {
     try {
       let mimeType = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService)
                                               .getTypeFromURI(aUri);
       if (mimeType == "application/x-xpinstall") {
         let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-        AddonManager.getInstallForURL(aUri.spec, null, mimeType).then(install => {
+        AddonManager.getInstallForURL(aUri.spec, mimeType).then(install => {
           AddonManager.installAddonFromWebpage(mimeType, aBrowser, systemPrincipal,
                                                install);
         });
         return true;
       }
     } catch (e) {
       return false;
     }
--- a/browser/base/content/test/general/browser_bug592338.js
+++ b/browser/base/content/test/general/browser_bug592338.js
@@ -98,17 +98,17 @@ async function runNextTest() {
   TESTS.shift()();
 }
 
 async function test() {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref("extensions.logging.enabled", true);
 
-  let aInstall = await AddonManager.getInstallForURL(TESTROOT + "theme.xpi", null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(TESTROOT + "theme.xpi", "application/x-xpinstall");
   aInstall.addListener({
     async onInstallEnded() {
       let aAddon = await AddonManager.getAddonByID("theme-xpi@tests.mozilla.org");
       isnot(aAddon, null, "Should have installed the test theme.");
 
       runNextTest();
     }
   });
--- a/browser/base/content/test/webextensions/head.js
+++ b/browser/base/content/test/webextensions/head.js
@@ -68,17 +68,17 @@ function promiseInstallEvent(addon, even
  * @param {string} url
  *        URL of the .xpi file to install
  *
  * @returns {Promise}
  *          Resolves when the extension has been installed with the Addon
  *          object as the resolution value.
  */
 async function promiseInstallAddon(url) {
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   install.install();
 
   let addon = await new Promise(resolve => {
     install.addListener({
       onInstallEnded(_install, _addon) {
         resolve(_addon);
       },
     });
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -409,17 +409,17 @@ var Policies = {
               try {
                 xpiFile.initWithPath(location);
               } catch (e) {
                 log.error(`Invalid extension path location - ${location}`);
                 continue;
               }
               url = Services.io.newFileURI(xpiFile).spec;
             }
-            AddonManager.getInstallForURL(url, null, "application/x-xpinstall").then(install => {
+            AddonManager.getInstallForURL(url, "application/x-xpinstall").then(install => {
               if (install.addon && install.addon.appDisabled) {
                 log.error(`Incompatible add-on - ${location}`);
                 install.cancel();
                 return;
               }
               let listener = {
               /* eslint-disable-next-line no-shadow */
                 onDownloadEnded: (install) => {
--- a/devtools/client/webide/modules/addons.js
+++ b/devtools/client/webide/modules/addons.js
@@ -76,17 +76,17 @@ Addon.prototype = {
     if (addon && !addon.userDisabled) {
       this.status = "installed";
       return;
     }
     this.status = "preparing";
     if (addon && addon.userDisabled) {
       addon.userDisabled = false;
     } else {
-      let install = await AddonManager.getInstallForURL(this.xpiLink, null, "application/x-xpinstall");
+      let install = await AddonManager.getInstallForURL(this.xpiLink, "application/x-xpinstall");
       install.addListener(this);
       install.install();
     }
   },
 
   uninstall: async function() {
     let addon = await AddonManager.getAddonByID(this.addonID);
     addon.uninstall();
--- a/services/sync/modules/addonutils.js
+++ b/services/sync/modules/addonutils.js
@@ -33,23 +33,17 @@ AddonUtilsInternal.prototype = {
     this._log.debug("Obtaining install for " + addon.id);
 
     // We should theoretically be able to obtain (and use) addon.install if
     // it is available. However, the addon.sourceURI rewriting won't be
     // reflected in the AddonInstall, so we can't use it. If we ever get rid
     // of sourceURI rewriting, we can avoid having to reconstruct the
     // AddonInstall.
     return AddonManager.getInstallForURL(
-      addon.sourceURI.spec,
-      null,
-      "application/x-xpinstall",
-      undefined,
-      addon.name,
-      addon.iconURL,
-      addon.version
+      addon.sourceURI.spec, "application/x-xpinstall", undefined, addon.name, addon.iconURL, addon.version
     );
   },
 
   /**
    * Installs an add-on from an AddonSearchResult instance.
    *
    * The options argument defines extra options to control the install.
    * Recognized keys in this map are:
--- a/toolkit/components/normandy/lib/Addons.jsm
+++ b/toolkit/components/normandy/lib/Addons.jsm
@@ -57,17 +57,17 @@ var Addons = {
    * @async
    * @returns {string}
    *   Add-on ID that was installed
    * @throws {string}
    *   If the add-on can not be installed, or overwriting is disabled and an
    *   add-on with a matching ID is already installed.
    */
   async install(addonUrl, options) {
-    const installObj = await AddonManager.getInstallForURL(addonUrl, null, "application/x-xpinstall");
+    const installObj = await AddonManager.getInstallForURL(addonUrl, "application/x-xpinstall");
     return this.applyInstall(installObj, options);
   },
 
   async applyInstall(addonInstall, {update = false} = {}) {
     const result = new Promise((resolve, reject) => addonInstall.addListener({
       onInstallStarted(cbInstall) {
         if (cbInstall.existingAddon && !update) {
           reject(new Error(`
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -169,58 +169,16 @@ function safeCall(aCallback, ...aArgs) {
   try {
     aCallback.apply(null, aArgs);
   } catch (e) {
     logger.warn("Exception calling callback", e);
   }
 }
 
 /**
- * Creates a function that will call the passed callback catching and logging
- * any exceptions.
- *
- * @param  aCallback
- *         The callback method to call
- */
-function makeSafe(aCallback) {
-  return function(...aArgs) {
-    safeCall(aCallback, ...aArgs);
-  };
-}
-
-/**
- * Given a promise and an optional callback, either:
- *
- * 1) Returns the promise, if no callback was provided, or,
- * 2) Calls the callback with the promise resolution value, and reports
- *    any errors.
- *
- * @param {Promise} promise
- *        The promise to return, or report to the callback function.
- * @param {function | null} callback
- *        The optional callback function to call with the promise
- *        resolution.
- * @returns {Promise?}
- */
-function promiseOrCallback(promise, callback) {
-  if (!callback)
-    return promise;
-
-  if (typeof callback !== "function")
-    throw Components.Exception("Callback must be a function",
-                               Cr.NS_ERROR_INVALID_ARG);
-
-  promise.then(makeSafe(callback)).catch(error => {
-    logger.error(error);
-  });
-
-  return undefined;
-}
-
-/**
  * Report an exception thrown by a provider API method.
  */
 function reportProviderError(aProvider, aMethod, aError) {
   let method = `provider ${providerName(aProvider)}.${aMethod}`;
   AddonManagerPrivate.recordException("AMI", method, aError);
   logger.error("Exception calling " + method, aError);
 }
 
@@ -3381,29 +3339,24 @@ var AddonManager = {
   stateToString(state) {
     return this._stateToString.get(state);
   },
 
   errorToString(err) {
     return err ? this._errorToString.get(err) : null;
   },
 
-  getInstallForURL(aUrl, aCallback, aMimetype,
-                                                 aHash, aName, aIcons,
-                                                 aVersion, aBrowser) {
-    return promiseOrCallback(
-      AddonManagerInternal.getInstallForURL(aUrl, aMimetype, aHash,
-                                            aName, aIcons, aVersion, aBrowser),
-      aCallback);
+  getInstallForURL(aUrl, aMimetype, aHash, aName, aIcons,
+                   aVersion, aBrowser) {
+    return AddonManagerInternal.getInstallForURL(aUrl, aMimetype, aHash,
+                                                 aName, aIcons, aVersion, aBrowser);
   },
 
-  getInstallForFile(aFile, aCallback, aMimetype) {
-    return promiseOrCallback(
-      AddonManagerInternal.getInstallForFile(aFile, aMimetype),
-      aCallback);
+  getInstallForFile(aFile, aMimetype) {
+      return AddonManagerInternal.getInstallForFile(aFile, aMimetype);
   },
 
   /**
    * Gets an array of add-on IDs that changed during the most recent startup.
    *
    * @param  aType
    *         The type of startup change to get
    * @return An array of add-on IDs
--- a/toolkit/mozapps/extensions/addonManager.js
+++ b/toolkit/mozapps/extensions/addonManager.js
@@ -73,17 +73,17 @@ amManager.prototype = {
   installAddonFromWebpage(aMimetype, aBrowser, aInstallingPrincipal,
                           aUri, aHash, aName, aIcon, aCallback) {
     let retval = true;
     if (!AddonManager.isInstallAllowed(aMimetype, aInstallingPrincipal)) {
       aCallback = null;
       retval = false;
     }
 
-    AddonManager.getInstallForURL(aUri, null, aMimetype, aHash, aName, aIcon, null, aBrowser).then(aInstall => {
+    AddonManager.getInstallForURL(aUri, aMimetype, aHash, aName, aIcon, null, aBrowser).then(aInstall => {
       function callCallback(uri, status) {
         try {
           aCallback.onInstallEnded(uri, status);
         } catch (e) {
           Cu.reportError(e);
         }
       }
 
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -3467,17 +3467,17 @@ var gDragDrop = {
       } else {
         let file = dataTransfer.mozGetDataAt("application/x-moz-file", i);
         if (file) {
           url = Services.io.newFileURI(file).spec;
         }
       }
 
       if (url) {
-        let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+        let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
         AddonManager.installAddonFromAOM(browser, document.documentURIObject, install);
       }
     }
   }
 };
 
 // Stub tabbrowser implementation for use by the tab-modal alert code
 // when an alert/prompt/confirm method is called in a WebExtensions options_ui page
--- a/toolkit/mozapps/extensions/test/AddonManagerTesting.jsm
+++ b/toolkit/mozapps/extensions/test/AddonManagerTesting.jsm
@@ -84,17 +84,17 @@ var AddonManagerTesting = {
   /**
    * Install an XPI add-on from a URL.
    *
    * @return Promise<addon>
    */
   installXPIFromURL(url, hash, name, iconURL, version) {
     return new Promise(async (resolve, reject) => {
 
-      let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", hash, name, iconURL, version);
+      let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", hash, name, iconURL, version);
       let fail = () => { reject(new Error("Add-on install failed.")); };
 
       let listener = {
         onDownloadCancelled: fail,
         onDownloadFailed: fail,
         onInstallCancelled: fail,
         onInstallFailed: fail,
         onInstallEnded(install, addon) {
--- a/toolkit/mozapps/extensions/test/browser/browser_bug596336.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug596336.js
@@ -22,17 +22,17 @@ function get_node(parent, anonid) {
 }
 
 function get_class_node(parent, cls) {
   return parent.ownerDocument.getAnonymousElementByAttribute(parent, "class", cls);
 }
 
 function install_addon(aXpi) {
   return new Promise(async resolve => {
-    let aInstall = await AddonManager.getInstallForURL(TESTROOT + "addons/" + aXpi + ".xpi", null, "application/x-xpinstall");
+    let aInstall = await AddonManager.getInstallForURL(TESTROOT + "addons/" + aXpi + ".xpi", "application/x-xpinstall");
     aInstall.addListener({
       onInstallEnded(aInstall) {
         resolve();
       }
     });
     aInstall.install();
   });
 }
--- a/toolkit/mozapps/extensions/test/browser/browser_installssl.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_installssl.js
@@ -75,17 +75,17 @@ function run_install_tests(callback) {
       var message = "Should have seen the right result for an install redirected from " +
                     mainURL + " to " + redirectURL;
     } else {
       url = mainURL + xpi;
       message = "Should have seen the right result for an install from " +
                 mainURL;
     }
 
-    let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+    let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
     gPendingInstall = install;
     install.addListener({
       onDownloadEnded(install) {
         is(SUCCESS, expectedStatus, message);
         info("Install test ran in " + (Date.now() - gLast) + "ms");
         // Don't proceed with the install
         install.cancel();
         gPendingInstall = null;
--- a/toolkit/mozapps/extensions/test/browser/browser_update.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_update.js
@@ -13,29 +13,29 @@ function test() {
     ["xpinstall.signatures.required", false]
   ]});
 
   run_next_test();
 }
 
 // Install a first version
 add_test(async function() {
-  let aInstall = await AddonManager.getInstallForURL(TESTROOT + "addons/browser_update1_1.xpi", null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(TESTROOT + "addons/browser_update1_1.xpi", "application/x-xpinstall");
   aInstall.install();
 
   Services.ppmm.addMessageListener("my-addon-1", function messageListener() {
     Services.ppmm.removeMessageListener("my-addon-1", messageListener);
     ok(true, "first version sent frame script message");
     run_next_test();
   });
 });
 
 // Update to a second version and verify that content gets updated
 add_test(async function() {
-  let aInstall = await AddonManager.getInstallForURL(TESTROOT + "addons/browser_update1_2.xpi", null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(TESTROOT + "addons/browser_update1_2.xpi", "application/x-xpinstall");
   aInstall.install();
 
   Services.ppmm.addMessageListener("my-addon-2", function messageListener() {
     Services.ppmm.removeMessageListener("my-addon-2", messageListener);
     ok(true, "second version sent frame script message");
     run_next_test();
   });
 });
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -519,17 +519,17 @@ function promiseAddonsByIDs(aIDs) {
 }
 /**
  * Install an add-on and call a callback when complete.
  *
  * The callback will receive the Addon for the installed add-on.
  */
 function install_addon(path, cb, pathPrefix = TESTROOT) {
   let p = new Promise(async (resolve, reject) => {
-    let install = await AddonManager.getInstallForURL(pathPrefix + path, null, "application/x-xpinstall");
+    let install = await AddonManager.getInstallForURL(pathPrefix + path, "application/x-xpinstall");
     install.addListener({
       onInstallEnded: () => resolve(install.addon),
     });
 
     install.install();
   });
 
   return log_callback(p, cb);
--- a/toolkit/mozapps/extensions/test/mochitest/test_bug687194.html
+++ b/toolkit/mozapps/extensions/test/mochitest/test_bug687194.html
@@ -54,17 +54,17 @@
       mm.sendAsyncMessage("test687194:resolveChromeURI",
                           { URI: "chrome://bug687194/content/e10sbug.js" });
       lastResult = yield;
       is(lastResult.threw, true, "URI shouldn't resolve to begin with");
 
       let { AddonManager } = SpecialPowers.Cu.import("resource://gre/modules/AddonManager.jsm", {});
       const INSTALL_URI =
         "http://mochi.test:8888/tests/toolkit/mozapps/extensions/test/mochitest/file_bug687194.xpi";
-      let install = await AddonManager.getInstallForURL(INSTALL_URI, null, "application/x-xpinstall");
+      let install = await AddonManager.getInstallForURL(INSTALL_URI, "application/x-xpinstall");
       install = SpecialPowers.wrap(install);
       install.addListener(SpecialPowers.wrapCallbackObject({
         /* eslint no-shadow: 0 */
         onInstallEnded(install, addon) {
           SimpleTest.executeSoon(() => test.next(addon));
         }
       }));
       install.install();
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
@@ -180,25 +180,22 @@ add_task(async function setup() {
 
   await promiseStartupManager();
 
   // Install an add-on so can check that it isn't returned in the results
   await promiseInstallFile(xpis[0]);
   await promiseRestartManager();
 
   // Create an active AddonInstall so can check that it isn't returned in the results
-  let install = await AddonManager.getInstallForURL(BASE_URL + INSTALL_URL2,
-                                                    undefined,
-                                                    "application/x-xpinstall");
+  let install = await AddonManager.getInstallForURL(BASE_URL + INSTALL_URL2, "application/x-xpinstall");
   let promise = promiseCompleteInstall(install);
   registerCleanupFunction(() => promise);
 
   // Create a non-active AddonInstall so can check that it is returned in the results
-  await AddonManager.getInstallForURL(BASE_URL + INSTALL_URL3,
-                                      undefined, "application/x-xpinstall");
+  await AddonManager.getInstallForURL(BASE_URL + INSTALL_URL3, "application/x-xpinstall");
 });
 
 // Tests homepageURL and getSearchURL()
 add_task(async function test_1() {
   function check_urls(aPreference, aGetURL, aTests) {
     aTests.forEach(function(aTest) {
       Services.prefs.setCharPref(aPreference, aTest.preferenceValue);
       Assert.equal(aGetURL(aTest), aTest.expectedURL);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
@@ -624,18 +624,17 @@ function Pbackground_update() {
 }
 
 // Manually updates the test add-ons to the given version
 function Pmanual_update(aVersion) {
   let Pinstalls = [];
   for (let name of ["soft1", "soft2", "soft3", "soft4", "hard1", "regexp1"]) {
     Pinstalls.push(
       AddonManager.getInstallForURL(
-        `http://example.com/addons/blocklist_${name}_${aVersion}.xpi`,
-        null, "application/x-xpinstall"));
+        `http://example.com/addons/blocklist_${name}_${aVersion}.xpi`, "application/x-xpinstall"));
   }
 
   return Promise.all(Pinstalls).then(installs => {
     let completePromises = [];
     for (let install of installs) {
       completePromises.push(new Promise(resolve => {
         install.addListener({
           onDownloadCancelled: resolve,
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
@@ -1129,17 +1129,17 @@ add_task(async function test_22() {
 
 // Tests that installing from a URL doesn't require a restart
 add_task(async function test_23() {
   prepare_test({}, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_bootstrap1_1.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
 
   ensure_test_completed();
 
   notEqual(install, null);
 
   await new Promise(resolve => {
     prepare_test({}, [
       "onDownloadStarted",
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js
@@ -416,18 +416,17 @@ add_task(async function test_17() {
 
 // Tests that installing from a URL doesn't require a restart
 add_task(async function test_23() {
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_dictionary.xpi";
-  let install = await AddonManager.getInstallForURL(url, null,
-                                                    "application/x-xpinstall");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   ensure_test_completed();
 
   notEqual(install, null);
 
   await new Promise(resolve => {
     prepare_test({ }, [
       "onDownloadStarted",
       "onDownloadEnded"
--- a/toolkit/mozapps/extensions/test/xpcshell/test_error.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_error.js
@@ -48,17 +48,17 @@ async function run_test_3() {
   Assert.equal(install.error, AddonManager.ERROR_CORRUPT_FILE);
 
   run_test_4();
 }
 
 // Checks that a file that doesn't match its hash shows an error
 async function run_test_4() {
   let url = Services.io.newFileURI(do_get_file("data/unsigned.xpi")).spec;
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", "sha1:foo");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", "sha1:foo");
   Assert.notEqual(install, null);
   Assert.equal(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
   Assert.equal(install.error, AddonManager.ERROR_INCORRECT_HASH);
 
   run_test_5();
 }
 
 // Checks that a file that doesn't exist shows an error
--- a/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
@@ -121,17 +121,17 @@ add_task(async function test_addon_over_
           minVersion: "1",
           maxVersion: "1"}],
     },
   });
 
   testserver.registerFile("/addons/test_filepointer.xpi", xpi);
 
   let url = "http://example.com/addons/test_filepointer.xpi";
-  let install = await AddonManager.getInstallForURL(url, undefined, "application/x-xpinstall");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   await new Promise(resolve => {
     ensure_test_completed();
 
     prepare_test({
       "addon1@tests.mozilla.org": [
         ["onInstalling", false],
         ["onInstalled", false],
       ]
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js
@@ -282,17 +282,17 @@ add_task(async function test_1() {
   let { id, version } = a1;
   await promiseRestartManager();
   do_check_not_in_crash_annotation(id, version);
 });
 
 // Tests that an install from a url downloads.
 add_task(async function test_2() {
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", null, "Test 2", null, "1.0");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", null, "Test 2", null, "1.0");
   checkInstall(install, {
     version: "1.0",
     name: "Test 2",
     state: AddonManager.STATE_AVAILABLE,
     iconURL: null,
     sourceURI: Services.io.newURI(url),
   });
 
@@ -378,17 +378,17 @@ add_task(async function test_2() {
 
 // Tests that installing a new version of an existing add-on works
 add_task(async function test_4() {
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install2_2.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", null, "Test 3", null, "3.0");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", null, "Test 3", null, "3.0");
   ensure_test_completed();
 
   checkInstall(install, {
     version: "3.0",
     name: "Test 3",
     state: AddonManager.STATE_AVAILABLE,
     existingAddon: null,
   });
@@ -466,17 +466,17 @@ add_task(async function test_4() {
 add_task(async function test_6() {
   await promiseRestartManager();
 
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install3.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", null, "Real Test 4", null, "1.0");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", null, "Real Test 4", null, "1.0");
   ensure_test_completed();
 
   checkInstall(install, {
     version: "1.0",
     name: "Real Test 4",
     state: AddonManager.STATE_AVAILABLE,
   });
 
@@ -591,17 +591,17 @@ add_task(async function test_8() {
 add_task(async function test_9() {
   await promiseRestartManager();
 
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install3.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", null, "Real Test 4", null, "1.0");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", null, "Real Test 4", null, "1.0");
   ensure_test_completed();
 
   checkInstall(install, {
     version: "1.0",
     name: "Real Test 4",
     state: AddonManager.STATE_AVAILABLE,
   });
 
@@ -636,17 +636,17 @@ add_task(async function test_9() {
 add_task(async function test_14() {
   await promiseRestartManager();
 
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   ensure_test_completed();
 
   equal(install.file, null);
 
   install = await new Promise(resolve => {
     prepare_test({ }, [
       "onDownloadStarted"
     ], resolve);
@@ -683,17 +683,17 @@ add_task(async function test_14() {
 
 // Checks that cancelling the install from onDownloadEnded actually cancels it
 add_task(async function test_15() {
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   ensure_test_completed();
 
   equal(install.file, null);
 
   await new Promise(resolve => {
     prepare_test({ }, [
       "onDownloadStarted",
       "onDownloadEnded"
@@ -717,17 +717,17 @@ add_task(async function test_15() {
   });
 });
 
 // Verify that the userDisabled value carries over to the upgrade by default
 add_task(async function test_16() {
   await promiseRestartManager();
 
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   await new Promise(resolve => {
     aInstall.addListener({
       onInstallStarted() {
         ok(!aInstall.addon.userDisabled);
         aInstall.addon.userDisabled = true;
       },
 
       onInstallEnded() {
@@ -741,17 +741,17 @@ add_task(async function test_16() {
 
   let a2 = await AddonManager.getAddonByID("addon2@tests.mozilla.org");
   checkAddon("addon2@tests.mozilla.org", a2, {
     userDisabled: true,
     isActive: false,
   });
 
   let url_2 = "http://example.com/addons/test_install2_2.xpi";
-  let aInstall_2 = await AddonManager.getInstallForURL(url_2, null, "application/x-xpinstall");
+  let aInstall_2 = await AddonManager.getInstallForURL(url_2, "application/x-xpinstall");
   await new Promise(resolve => {
     aInstall_2.addListener({
       onInstallEnded() {
         resolve();
       }
     });
     aInstall_2.install();
   });
@@ -772,17 +772,17 @@ add_task(async function test_16() {
   a2_2.uninstall();
 });
 
 // Verify that changing the userDisabled value before onInstallEnded works
 add_task(async function test_17() {
   await promiseRestartManager();
 
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   await new Promise(resolve => {
     aInstall.addListener({
       onInstallEnded() {
         resolve();
       }
     });
     aInstall.install();
   });
@@ -793,17 +793,17 @@ add_task(async function test_17() {
 
   let a2 = await AddonManager.getAddonByID("addon2@tests.mozilla.org");
   checkAddon("addon2@tests.mozilla.org", a2, {
     userDisabled: false,
     isActive: true,
   });
 
   let url_2 = "http://example.com/addons/test_install2_2.xpi";
-  let aInstall_2 = await AddonManager.getInstallForURL(url_2, null, "application/x-xpinstall");
+  let aInstall_2 = await AddonManager.getInstallForURL(url_2, "application/x-xpinstall");
 
   await new Promise(resolve => {
     aInstall_2.addListener({
       onInstallStarted() {
         ok(!aInstall_2.addon.userDisabled);
         aInstall_2.addon.userDisabled = true;
       },
 
@@ -824,17 +824,17 @@ add_task(async function test_17() {
   a2_2.uninstall();
 });
 
 // Verify that changing the userDisabled value before onInstallEnded works
 add_task(async function test_18() {
   await promiseRestartManager();
 
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   await new Promise(resolve => {
     aInstall.addListener({
       onInstallStarted() {
         ok(!aInstall.addon.userDisabled);
         aInstall.addon.userDisabled = true;
       },
 
       onInstallEnded() {
@@ -848,17 +848,17 @@ add_task(async function test_18() {
 
   let a2 = await AddonManager.getAddonByID("addon2@tests.mozilla.org");
   checkAddon("addon2@tests.mozilla.org", a2, {
     userDisabled: true,
     isActive: false,
   });
 
   let url_2 = "http://example.com/addons/test_install2_2.xpi";
-  let aInstall_2 = await AddonManager.getInstallForURL(url_2, null, "application/x-xpinstall");
+  let aInstall_2 = await AddonManager.getInstallForURL(url_2, "application/x-xpinstall");
   await new Promise(resolve => {
     aInstall_2.addListener({
       onInstallStarted() {
         ok(aInstall_2.addon.userDisabled);
         aInstall_2.addon.userDisabled = false;
       },
 
       onInstallEnded() {
@@ -888,17 +888,17 @@ add_task(async function test_18_1() {
   Services.prefs.setCharPref(PREF_GETADDONS_BYIDS,
                              "http://example.com/data/test_install_addons.json");
   Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES,
                              "http://example.com/data/test_install_compat.json");
 
   Services.prefs.setBoolPref("extensions.addon2@tests.mozilla.org.getAddons.cache.enabled", false);
 
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
 
   let addon = await new Promise(resolve => {
     aInstall.addListener({
       onInstallEnded(unused, aAddon) {
         resolve(aAddon);
       }
     });
     aInstall.install();
@@ -916,17 +916,17 @@ add_task(async function test_18_1() {
 
 // Checks that metadata is downloaded for new installs and is visible before and
 // after restart
 add_task(async function test_19() {
   await promiseRestartManager();
   Services.prefs.setBoolPref("extensions.addon2@tests.mozilla.org.getAddons.cache.enabled", true);
 
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   await new Promise(resolve => {
     aInstall.addListener({
       onInstallEnded(unused, aAddon) {
         resolve(aAddon);
       }
     });
     aInstall.install();
   });
@@ -942,17 +942,17 @@ add_task(async function test_19() {
   a2.uninstall();
 });
 
 // Do the same again to make sure it works when the data is already in the cache
 add_task(async function test_20() {
   await promiseRestartManager();
 
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   await new Promise(resolve => {
     aInstall.addListener({
       onInstallEnded(unused, aAddon) {
         resolve(aAddon);
       }
     });
     aInstall.install();
   });
@@ -970,17 +970,17 @@ add_task(async function test_20() {
 
 // Tests that an install can be restarted after being cancelled
 add_task(async function test_22() {
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install3.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   ensure_test_completed();
 
   checkInstall(aInstall, {
     state: AddonManager.STATE_AVAILABLE,
   });
 
   let install = await new Promise(resolve => {
     prepare_test({}, [
@@ -1023,17 +1023,17 @@ add_task(async function test_22() {
 // Tests that an install can be restarted after being cancelled when a hash
 // was provided
 add_task(async function test_23() {
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install3.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", do_get_file_hash(XPIS.test_install3));
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", do_get_file_hash(XPIS.test_install3));
 
   ensure_test_completed();
 
   checkInstall(install, {
     state: AddonManager.STATE_AVAILABLE,
   });
 
   await new Promise(resolve => {
@@ -1078,17 +1078,17 @@ add_task(async function test_23() {
 // Tests that an install with a bad hash can be restarted after it fails, though
 // it will only fail again
 add_task(async function test_24() {
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install3.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", "sha1:foo");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall", "sha1:foo");
   ensure_test_completed();
 
   checkInstall(aInstall, {
     state: AddonManager.STATE_AVAILABLE,
   });
 
   let install = await new Promise(resolve => {
     prepare_test({}, [
@@ -1110,17 +1110,17 @@ add_task(async function test_24() {
 
 // Tests that installs with a hash for a local file work
 add_task(async function test_25() {
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = Services.io.newFileURI(XPIS.test_install3).spec;
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", do_get_file_hash(XPIS.test_install3));
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall", do_get_file_hash(XPIS.test_install3));
   ensure_test_completed();
 
   checkInstall(aInstall, {
     state: AddonManager.STATE_DOWNLOADED,
     error: 0,
   });
 
   prepare_test({ }, [
@@ -1135,17 +1135,17 @@ add_task(async function test_25() {
 add_task(async function test_26() {
   prepare_test({ }, [
     "onNewInstall",
     "onDownloadStarted",
     "onDownloadCancelled"
   ]);
 
   let url = "http://example.com/redirect?/addons/test_install1.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
 
   await new Promise(resolve => {
     let observerService = Cc["@mozilla.org/network/http-activity-distributor;1"].
                           getService(Ci.nsIHttpActivityDistributor);
     observerService.addObserver({
       observeActivity(aChannel, aType, aSubtype, aTimestamp, aSizeData,
                                 aStringData) {
         aChannel.QueryInterface(Ci.nsIChannel);
@@ -1178,17 +1178,17 @@ add_task(async function test_26() {
 // Tests that an install can be restarted during onDownloadCancelled after being
 // cancelled in mid-download
 add_task(async function test_27() {
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install3.xpi";
-  let aInstall = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let aInstall = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   ensure_test_completed();
 
   checkInstall(aInstall, {
     state: AddonManager.STATE_AVAILABLE,
   });
 
   aInstall.addListener({
     onDownloadProgress() {
@@ -1235,17 +1235,17 @@ add_task(async function test_27() {
 add_task(async function test_29() {
   Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", true);
 
   prepare_test({ }, [
     "onNewInstall"
   ]);
 
   let url = "http://example.com/addons/test_install6.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall", null, "Addon Test 6", null, "1.0");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", null, "Addon Test 6", null, "1.0");
   ensure_test_completed();
 
   checkInstall(install, {
     version: "1.0",
     name: "Addon Test 6",
     state: AddonManager.STATE_AVAILABLE,
   });
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install_icons.js
@@ -16,42 +16,42 @@ function run_test() {
   do_test_pending();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   startupManager();
 
   test_1();
 }
 
 async function test_1() {
-  let aInstall = await AddonManager.getInstallForURL(addon_url, null, "application/x-xpinstall", null, null, null, null, null);
+  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);
   Assert.equal(aInstall.icons[32], undefined);
   Assert.equal(aInstall.icons[64], undefined);
   test_2();
 }
 
 async function test_2() {
-  let aInstall = await AddonManager.getInstallForURL(addon_url, null, "application/x-xpinstall", null, null, icon32_url, null, null);
+  let aInstall = await AddonManager.getInstallForURL(addon_url, "application/x-xpinstall", null, null, icon32_url, null, null);
   Assert.equal(aInstall.iconURL, icon32_url);
   Assert.notEqual(aInstall.icons, null);
   Assert.equal(aInstall.icons[32], icon32_url);
   Assert.equal(aInstall.icons[64], undefined);
   test_3();
 }
 
 async function test_3() {
-  let aInstall = await AddonManager.getInstallForURL(addon_url, null, "application/x-xpinstall", null, null, { "32": icon32_url }, null, null);
+  let aInstall = await AddonManager.getInstallForURL(addon_url, "application/x-xpinstall", null, null, { "32": icon32_url }, null, null);
   Assert.equal(aInstall.iconURL, icon32_url);
   Assert.notEqual(aInstall.icons, null);
   Assert.equal(aInstall.icons[32], icon32_url);
   Assert.equal(aInstall.icons[64], undefined);
   test_4();
 }
 
 async function test_4() {
-  let aInstall = await AddonManager.getInstallForURL(addon_url, null, "application/x-xpinstall", null, null, { "32": icon32_url, "64": icon64_url }, null, null);
+  let aInstall = await AddonManager.getInstallForURL(addon_url, "application/x-xpinstall", null, null, { "32": icon32_url, "64": icon64_url }, null, null);
   Assert.equal(aInstall.iconURL, icon32_url);
   Assert.notEqual(aInstall.icons, null);
   Assert.equal(aInstall.icons[32], icon32_url);
   Assert.equal(aInstall.icons[64], icon64_url);
   executeSoon(do_test_finished);
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
@@ -72,17 +72,17 @@ function createBrokenAddonRemove(file) {
   zipW.open(brokenFile, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
   zipW.removeEntry("test.txt", false);
   zipW.close();
 
   return brokenFile;
 }
 
 function createInstall(url) {
-  return AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  return AddonManager.getInstallForURL(url, "application/x-xpinstall");
 }
 
 function serveUpdateRDF(leafName) {
   gServer.registerPathHandler("/update.rdf", function(request, response) {
     response.setStatusLine(request.httpVersion, 200, "OK");
     response.write(JSON.stringify({
       addons: {
         [ID]: {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
@@ -90,17 +90,17 @@ add_test(async function test_getter_and_
 
 add_test(async function test_fetch_by_guid_unknown_guid() {
   let addon = await XPIProvider.getAddonBySyncGUID("XXXX");
   Assert.equal(null, addon);
   run_next_test();
 });
 
 // Ensure setting an extension to an existing syncGUID results in error.
-add_test(function test_error_on_duplicate_syncguid_insert() {
+add_test(async function test_error_on_duplicate_syncguid_insert() {
   const installNames = ["test_install1", "test_install2_1"];
   const installIDs = ["addon1@tests.mozilla.org", "addon2@tests.mozilla.org"];
 
   let installCount = 0;
 
   let listener = {
     onInstallEnded: function onInstallEnded() {
       installCount++;
@@ -125,20 +125,20 @@ add_test(function test_error_on_duplicat
           run_next_test();
         }
        });
       }
     }
   };
 
   AddonManager.addInstallListener(listener);
-  let getInstallCB = function(install) { install.install(); };
 
   for (let xpi of XPIS) {
-    AddonManager.getInstallForFile(xpi, getInstallCB);
+    let install = await AddonManager.getInstallForFile(xpi);
+    install.install();
   }
 });
 
 add_test(async function test_fetch_by_guid_known_guid() {
   let addon = await AddonManager.getAddonByID(addonId);
   Assert.notEqual(null, addon);
   Assert.notEqual(null, addon.syncGUID);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update.js
@@ -869,25 +869,25 @@ add_task(async function test_14() {
 
   notEqual(a8, null);
   equal(a8.version, "1.0");
   a8.uninstall();
 });
 
 add_task(async function test_16() {
   let url = "http://example.com/addons/test_install2_1.xpi";
-  let install = await AddonManager.getInstallForURL(url, null, "application/x-xpinstall");
+  let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall");
   await promiseCompleteInstall(install);
 
   let a1 = await AddonManager.getAddonByID("addon2@tests.mozilla.org");
   notEqual(a1.syncGUID, null);
   let oldGUID = a1.syncGUID;
 
   let url_2 = "http://example.com/addons/test_install2_2.xpi";
-  let install_2 = await AddonManager.getInstallForURL(url_2, null, "application/x-xpinstall");
+  let install_2 = await AddonManager.getInstallForURL(url_2, "application/x-xpinstall");
   await promiseCompleteInstall(install_2);
 
   let a2 = await AddonManager.getAddonByID("addon2@tests.mozilla.org");
   notEqual(a2.syncGUID, null);
   equal(oldGUID, a2.syncGUID);
 
   a2.uninstall();
 });