diff --git a/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul b/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul index 54792b02b76..edf9967dbec 100644 --- a/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul +++ b/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul @@ -67,21 +67,22 @@ function runTest() { file.append(FILE_UPDATE_ARCHIVE); ok(!file.exists(), file.path + " should not exist"); - let addonPrepDir = Services.dirsvc.get(NS_APP_USER_PROFILE_50_DIR, - Ci.nsILocalFile); - addonPrepDir.append(ADDON_PREP_DIR); - // Not being able to remove the directory used to create the test add-ons - // will not adversely affect subsequent tests so wrap it in a try block and - // don't test whether its removal was successful. - try { - removeDirRecursive(addonPrepDir); - } - catch (e) { - logTestInfo("Unable to remove directory. Path: " + addonPrepDir.path + - ", Exception: " + e); - } - - resetAddons(cleanupRestoreUpdaterBackup); + resetAddons(() => { + let addonPrepDir = Services.dirsvc.get(NS_APP_USER_PROFILE_50_DIR, + Ci.nsILocalFile); + addonPrepDir.append(ADDON_PREP_DIR); + // Not being able to remove the directory used to create the test add-ons + // will not adversely affect subsequent tests so wrap it in a try block and + // don't test whether its removal was successful. + try { + removeDirRecursive(addonPrepDir); + } + catch (e) { + logTestInfo("Unable to remove directory. Path: " + addonPrepDir.path + + ", Exception: " + e); + } + cleanupRestoreUpdaterBackup(); + }); } /** diff --git a/toolkit/mozapps/update/tests/chrome/utils.js b/toolkit/mozapps/update/tests/chrome/utils.js index c8525a947ad..cb726c80fae 100644 --- a/toolkit/mozapps/update/tests/chrome/utils.js +++ b/toolkit/mozapps/update/tests/chrome/utils.js @@ -1316,45 +1316,14 @@ function setupAddons(aCallback) { Services.prefs.setCharPref(PREF_DISABLEDADDONS, disabledAddons.join(" ")); // Install the test add-ons. - let xpiFiles = getTestAddonXPIFiles(); - let xpiCount = xpiFiles.length; - let installs = []; - xpiFiles.forEach(function(aFile) { - AddonManager.getInstallForFile(aFile, function(aInstall) { - if (!aInstall) { - throw "No AddonInstall created for " + aFile.path; - } - - installs.push(aInstall); - - if (--xpiCount == 0) { - let installCount = installs.length; - let installCompleted = function(aInstall) { - aInstall.removeListener(listener); - - if (getAddonTestType(aInstall.addon.name) == "userdisabled") { - aInstall.addon.userDisabled = true; - } - if (--installCount == 0) { - setNoUpdateAddonsDisabledState(); - } - }; - - let listener = { - onDownloadFailed: installCompleted, - onDownloadCancelled: installCompleted, - onInstallFailed: installCompleted, - onInstallCancelled: installCompleted, - onInstallEnded: installCompleted - }; - - installs.forEach(function(aInstall) { - aInstall.addListener(listener); - aInstall.install(); - }); + let promises = getTestAddonXPIFiles().map(function(aFile) { + return AddonManager.installTemporaryAddon(aFile).then(addon => { + if (getAddonTestType(addon.name) == "userdisabled") { + addon.userDisabled = true; } }); }); + return Promise.all(promises).then(setNoUpdateAddonsDisabledState); }); }