B2G/gecko/toolkit/mozapps/update/test/chrome/utils.js
/**
 * Uninstalls the test add-ons, enables add-ons that were disabled when the
 * test started, and calls the callback specified in the aCallback parameter.
 *
 * @param  aCallback
 *         A callback to call after all operations have completed.
 */
Uninstalls the test add-ons, enables add-ons that were disabled when the
test started, and calls the callback specified in the aCallback parameter.

@param  aCallback
A callback to call after all operations have completed.
Uninstalls the test add - ons enables add - ons that were disabled when the test started and calls the callback specified in the aCallback parameter . @param aCallback A callback to call after all operations have completed .
function resetAddons(aCallback) {
  debugDump("entering");
  if (!Services.prefs.prefHasUserValue(PREF_DISABLEDADDONS)) {
    debugDump("preference " + PREF_DISABLEDADDONS + " doesn't exist... " +
              "returning early");
    aCallback();
    return;
  }
  let count = TEST_ADDONS.length;
  function uninstallCompleted(aAddon) {
    if (--count == 0) {
      AddonManager.removeAddonListener(listener);
      let disabledAddons = Services.prefs.getCharPref(PREF_DISABLEDADDONS).split(" ");
      Services.prefs.clearUserPref(PREF_DISABLEDADDONS);
      AddonManager.getAllAddons(function(aAddons) {
        aAddons.forEach(function(aAddon) {
          if (disabledAddons.indexOf(aAddon.id)) {
            aAddon.userDisabled = false;
          }
        });
        aCallback();
      });
    }
  }
  let listener = {
    onUninstalled: uninstallCompleted
  };
  AddonManager.addAddonListener(listener);
  TEST_ADDONS.forEach(function(aName) {
    AddonManager.getAddonByID(aName + ADDON_ID_SUFFIX, function(aAddon) {
      aAddon.uninstall();
    });
  });
}
function resetAddons ( aCallback ) { debugDump ( "entering" ) ; if ( ! Services . prefs . prefHasUserValue ( PREF_DISABLEDADDONS ) ) { debugDump ( "preference " + PREF_DISABLEDADDONS + " doesn't exist... " + "returning early" ) ; aCallback ( ) ; return ; } let count = TEST_ADDONS . length ; function uninstallCompleted ( aAddon ) { if ( -- count == 0 ) { AddonManager . removeAddonListener ( listener ) ; let disabledAddons = Services . prefs . getCharPref ( PREF_DISABLEDADDONS ) . split ( " " ) ; Services . prefs . clearUserPref ( PREF_DISABLEDADDONS ) ; AddonManager . getAllAddons ( function ( aAddons ) { aAddons . forEach ( function ( aAddon ) { if ( disabledAddons . indexOf ( aAddon . id ) ) { aAddon . userDisabled = false ; } } ) ; aCallback ( ) ; } ) ; } } let listener = { onUninstalled : uninstallCompleted } ; AddonManager . addAddonListener ( listener ) ; TEST_ADDONS . forEach ( function ( aName ) { AddonManager . getAddonByID ( aName + ADDON_ID_SUFFIX , function ( aAddon ) { aAddon . uninstall ( ) ; } ) ; } ) ; }
Uninstalls the test add-ons, enables add-ons that were disabled when the
 test started, and calls the callback specified in the aCallback parameter.
Uninstalls the test add - ons enables add - ons that were disabled when the test started and calls the callback specified in the aCallback parameter .
// If test_9999_cleanup.xul is ran by itself then the test add-ons will not // have been installed and any pre-existing add-ons will not have been // disabled so return early. // Uninstall the test add-ons. // Enable the pre-existing add-ons that were disabled so they wouldn't // interfere with the tests.