B2G/gecko/toolkit/mozapps/update/test/chrome/utils.js
/**
 * Resets the most common preferences used by tests to their original values.
 */
Resets the most common preferences used by tests to their original values.
Resets the most common preferences used by tests to their original values .
function resetPrefs() {
  if (gAppUpdateURL !== undefined) {
    Services.prefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, gAppUpdateURL);
  }
  else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_URL_OVERRIDE);
  }
  if (gAppUpdateURLDefault) {
    gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, gAppUpdateURLDefault);
  }
  if (gAppUpdateEnabled !== undefined) {
    Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, gAppUpdateEnabled);
  }
  else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_ENABLED)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_ENABLED);
  }
  if (gExtUpdateURL !== undefined) {
    Services.prefs.setCharPref(PREF_EXTENSIONS_UPDATE_URL, gExtUpdateURL);
  }
  else if (Services.prefs.prefHasUserValue(PREF_EXTENSIONS_UPDATE_URL)) {
    Services.prefs.clearUserPref(PREF_EXTENSIONS_UPDATE_URL);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_IDLETIME)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_IDLETIME);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_PROMPTWAITTIME)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_PROMPTWAITTIME);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_DETAILS)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_URL_DETAILS);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_SHOW_INSTALLED_UI)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_SHOW_INSTALLED_UI);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_LOG)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_LOG);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_ERRORS)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_ERRORS);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_MAXERRORS)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_MAXERRORS);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDERRORS);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDMAXERRORS)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDMAXERRORS);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_REQUIREBUILTIN)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_REQUIREBUILTIN);
  }
  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_CHECKATTRS)) {
    Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_CHECKATTRS);
  }
  try {
    CERT_ATTRS.forEach(function(aCertAttrName) {
      Services.prefs.clearUserPref(PREF_APP_UPDATE_CERTS_BRANCH + "1." +
                                   aCertAttrName);
    });
  }
  catch (e) {
  }
  try {
    Services.prefs.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
  }
  catch(e) {
  }
  if (Services.prefs.prefHasUserValue(PREF_EXTENSIONS_STRICT_COMPAT)) {
		Services.prefs.clearUserPref(PREF_EXTENSIONS_STRICT_COMPAT);
  }
  if (Services.prefs.prefHasUserValue(PREF_EM_HOTFIX_ID)) {
    Services.prefs.clearUserPref(PREF_EM_HOTFIX_ID);
  }
}
function resetPrefs ( ) { if ( gAppUpdateURL !== undefined ) { Services . prefs . setCharPref ( PREF_APP_UPDATE_URL_OVERRIDE , gAppUpdateURL ) ; } else if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_URL_OVERRIDE ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_URL_OVERRIDE ) ; } if ( gAppUpdateURLDefault ) { gDefaultPrefBranch . setCharPref ( PREF_APP_UPDATE_URL , gAppUpdateURLDefault ) ; } if ( gAppUpdateEnabled !== undefined ) { Services . prefs . setBoolPref ( PREF_APP_UPDATE_ENABLED , gAppUpdateEnabled ) ; } else if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_ENABLED ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_ENABLED ) ; } if ( gExtUpdateURL !== undefined ) { Services . prefs . setCharPref ( PREF_EXTENSIONS_UPDATE_URL , gExtUpdateURL ) ; } else if ( Services . prefs . prefHasUserValue ( PREF_EXTENSIONS_UPDATE_URL ) ) { Services . prefs . clearUserPref ( PREF_EXTENSIONS_UPDATE_URL ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_IDLETIME ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_IDLETIME ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_PROMPTWAITTIME ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_PROMPTWAITTIME ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_URL_DETAILS ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_URL_DETAILS ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_SHOW_INSTALLED_UI ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_SHOW_INSTALLED_UI ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_LOG ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_LOG ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_CERT_ERRORS ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_CERT_ERRORS ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_CERT_MAXERRORS ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_CERT_MAXERRORS ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_BACKGROUNDERRORS ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_BACKGROUNDERRORS ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_BACKGROUNDMAXERRORS ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_BACKGROUNDMAXERRORS ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_CERT_REQUIREBUILTIN ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_CERT_REQUIREBUILTIN ) ; } if ( Services . prefs . prefHasUserValue ( PREF_APP_UPDATE_CERT_CHECKATTRS ) ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_CERT_CHECKATTRS ) ; } try { CERT_ATTRS . forEach ( function ( aCertAttrName ) { Services . prefs . clearUserPref ( PREF_APP_UPDATE_CERTS_BRANCH + "1." + aCertAttrName ) ; } ) ; } catch ( e ) { } try { Services . prefs . deleteBranch ( PREF_APP_UPDATE_NEVER_BRANCH ) ; } catch ( e ) { } if ( Services . prefs . prefHasUserValue ( PREF_EXTENSIONS_STRICT_COMPAT ) ) { Services . prefs . clearUserPref ( PREF_EXTENSIONS_STRICT_COMPAT ) ; } if ( Services . prefs . prefHasUserValue ( PREF_EM_HOTFIX_ID ) ) { Services . prefs . clearUserPref ( PREF_EM_HOTFIX_ID ) ; } }
Resets the most common preferences used by tests to their original values.
Resets the most common preferences used by tests to their original values .