Bug 987512: Part 2 - Remove promise wrappers from AddonTestUtils. r?rhelmer
MozReview-Commit-ID: GyPguoX4r3d
--- a/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
@@ -1080,40 +1080,16 @@ var AddonTestUtils = {
file => this.promiseInstallFile(file, ignoreIncompatible)));
},
promiseCompleteAllInstalls(installs) {
return Promise.all(Array.from(installs, this.promiseCompleteInstall));
},
/**
- * A promise-based variant of AddonManager.getAddonsByIDs.
- *
- * @param {Array<string>} list
- * As the first argument of AddonManager.getAddonsByIDs
- * @return {Promise<Array<Addon>>}
- * Resolves to the array of add-ons for the given IDs.
- */
- promiseAddonsByIDs(list) {
- return new Promise(resolve => AddonManager.getAddonsByIDs(list, resolve));
- },
-
- /**
- * A promise-based variant of AddonManager.getAddonByID.
- *
- * @param {string} id
- * The ID of the add-on.
- * @return {Promise<Addon>}
- * Resolves to the add-on with the given ID.
- */
- promiseAddonByID(id) {
- return new Promise(resolve => AddonManager.getAddonByID(id, resolve));
- },
-
- /**
* Returns a promise that will be resolved when an add-on update check is
* complete. The value resolved will be an AddonInstall if a new version was
* found.
*
* @param {object} addon The add-on to find updates for.
* @param {integer} reason The type of update to find.
* @return {Promise<object>} an object containing information about the update.
*/
@@ -1163,29 +1139,16 @@ var AddonTestUtils = {
reject(result);
}
}
}, reason);
});
},
/**
- * A promise-based variant of AddonManager.getAddonsWithOperationsByTypes
- *
- * @param {Array<string>} types
- * The first argument to AddonManager.getAddonsWithOperationsByTypes
- * @return {Promise<Array<Addon>>}
- * Resolves to an array of add-ons with the given operations
- * pending.
- */
- promiseAddonsWithOperationsByTypes(types) {
- return new Promise(resolve => AddonManager.getAddonsWithOperationsByTypes(types, resolve));
- },
-
- /**
* Monitors console output for the duration of a task, and returns a promise
* which resolves to a tuple containing a list of all console messages
* generated during the task's execution, and the result of the task itself.
*
* @param {function} task
* The task to run while monitoring console output. May be
* either a generator function, per Task.jsm, or an ordinary
* function which returns promose.
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -64,20 +64,17 @@ const {
awaitPromise,
createAppInfo,
createInstallRDF,
createTempWebExtensionFile,
createUpdateRDF,
getFileForAddon,
manuallyInstall,
manuallyUninstall,
- promiseAddonByID,
promiseAddonEvent,
- promiseAddonsByIDs,
- promiseAddonsWithOperationsByTypes,
promiseCompleteAllInstalls,
promiseCompleteInstall,
promiseConsoleOutput,
promiseFindAddonUpdates,
promiseInstallAllFiles,
promiseInstallFile,
promiseRestartManager,
promiseSetExtensionModifiedTime,
@@ -142,16 +139,20 @@ Object.defineProperty(this, "TEST_UNPACK
return AddonTestUtils.testUnpacked = val;
},
});
// We need some internal bits of AddonManager
var AMscope = Components.utils.import("resource://gre/modules/AddonManager.jsm", {});
var { AddonManager, AddonManagerInternal, AddonManagerPrivate } = AMscope;
+const promiseAddonByID = AddonManager.getAddonByID;
+const promiseAddonsByIDs = AddonManager.getAddonsByIDs;
+const promiseAddonsWithOperationsByTypes = AddonManager.getAddonsWithOperationsByTypes;
+
var gPort = null;
var gUrlToFileMap = {};
// Map resource://xpcshell-data/ to the data directory
var resHandler = Services.io.getProtocolHandler("resource")
.QueryInterface(AM_Ci.nsISubstitutingProtocolHandler);
// Allow non-existent files because of bug 1207735
var dataURI = NetUtil.newURI(do_get_file("data", true));
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js
@@ -127,17 +127,17 @@ add_task(function*() {
{ id: NORMAL_ID, version: "2.0", path: "system1_2.xpi" },
];
let postponed = promiseInstallPostponed(IGNORE_ID, NORMAL_ID);
yield installSystemAddons(yield buildSystemAddonUpdates(updateList, root), testserver);
yield postponed;
// addon upgrade has been delayed.
- let addon_postponed = yield promiseAddonByID(IGNORE_ID, NORMAL_ID);
+ let addon_postponed = yield promiseAddonByID(IGNORE_ID);
do_check_neq(addon_postponed, null);
do_check_eq(addon_postponed.version, "1.0");
do_check_eq(addon_postponed.name, "System Test Delay Update Ignore");
do_check_true(addon_postponed.isCompatible);
do_check_false(addon_postponed.appDisabled);
do_check_true(addon_postponed.isActive);
do_check_eq(addon_postponed.type, "extension");
do_check_true(Services.prefs.getBoolPref(TEST_IGNORE_PREF));