Bug 1420514 - Replace app.update.enabled with app.update.disabledForTesting in update tests draft
authorKirk Steuber <ksteuber@mozilla.com>
Tue, 22 May 2018 09:16:33 -0700
changeset 818957 a6bfac7ee9432f43bab586885cef8529faed081d
parent 818956 be5c7b023eb4eab40e80fb6a398fe94f1199c8e1
push id116400
push userbmo:ksteuber@mozilla.com
push dateMon, 16 Jul 2018 20:42:55 +0000
bugs1420514
milestone63.0a1
Bug 1420514 - Replace app.update.enabled with app.update.disabledForTesting in update tests MozReview-Commit-ID: D92P83EB7EE
toolkit/mozapps/update/tests/browser/head.js
toolkit/mozapps/update/tests/chrome/test_0152_notify_backgroundCheckOfflineRetry.xul
toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul
toolkit/mozapps/update/tests/chrome/utils.js
toolkit/mozapps/update/tests/data/shared.js
toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
--- a/toolkit/mozapps/update/tests/browser/head.js
+++ b/toolkit/mozapps/update/tests/browser/head.js
@@ -115,17 +115,17 @@ function runUpdateTest(updateParams, che
       cleanUpUpdates();
     });
 
     gEnv.set("MOZ_TEST_SKIP_UPDATE_STAGE", "1");
     setUpdateTimerPrefs();
     await SpecialPowers.pushPrefEnv({
       set: [
         [PREF_APP_UPDATE_DOWNLOADPROMPTATTEMPTS, 0],
-        [PREF_APP_UPDATE_ENABLED, true],
+        [PREF_APP_UPDATE_DISABLEDFORTESTING, false],
         [PREF_APP_UPDATE_IDLETIME, 0],
         [PREF_APP_UPDATE_URL_MANUAL, URL_MANUAL_UPDATE],
         [PREF_APP_UPDATE_LOG, DEBUG_AUS_TEST],
       ]});
 
     await setupTestUpdater();
 
     let url = URL_HTTP_UPDATE_SJS +
@@ -168,20 +168,20 @@ function runUpdateProcessingTest(updates
     registerCleanupFunction(() => {
       gEnv.set("MOZ_TEST_SKIP_UPDATE_STAGE", "");
       UpdateListener.reset();
       cleanUpUpdates();
     });
 
     setUpdateTimerPrefs();
     gEnv.set("MOZ_TEST_SKIP_UPDATE_STAGE", "1");
-    SpecialPowers.pushPrefEnv({
+    await SpecialPowers.pushPrefEnv({
       set: [
         [PREF_APP_UPDATE_DOWNLOADPROMPTATTEMPTS, 0],
-        [PREF_APP_UPDATE_ENABLED, true],
+        [PREF_APP_UPDATE_DISABLEDFORTESTING, false],
         [PREF_APP_UPDATE_IDLETIME, 0],
         [PREF_APP_UPDATE_URL_MANUAL, URL_MANUAL_UPDATE],
         [PREF_APP_UPDATE_LOG, DEBUG_AUS_TEST],
       ]});
 
     await setupTestUpdater();
 
     writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
--- a/toolkit/mozapps/update/tests/chrome/test_0152_notify_backgroundCheckOfflineRetry.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0152_notify_backgroundCheckOfflineRetry.xul
@@ -28,17 +28,17 @@ const NETWORK_ERROR_OFFLINE = 111;
 var gProxyPrefValue;
 
 function runTest() {
   debugDump("entering");
 
   let url = URL_HTTP_UPDATE_XML + "?showDetails=1" + getVersionParams();
   setUpdateURL(url);
 
-  Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, true);
+  Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false);
   Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO, false);
 
   Services.io.offline = true;
   gProxyPrefValue = Services.prefs.getIntPref("network.proxy.type");
   Services.prefs.setIntPref("network.proxy.type", 0);
 
   gUpdateChecker.checkForUpdates(updateCheckListener, true);
 }
--- a/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul
@@ -37,19 +37,19 @@ function runTest() {
   SimpleTest.waitForExplicitFinish();
 
   if (DEBUG_AUS_TEST) {
     Services.prefs.setBoolPref(PREF_APP_UPDATE_LOG, true);
   }
 
   closeUpdateWindow();
 
-  // Always leave the app.update.enabled and app.update.staging.enabled
-  // preferences set to false when cleaning up.
-  Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, false);
+  // Always disable updates and update staging when cleaning up.
+  Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, true);
+  Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);  // Needed to disable updates
   Services.prefs.setBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, false);
 
   resetFiles();
   removeUpdateDirsAndFiles();
   reloadUpdateManagerData();
 
   let file = getUpdatesXMLFile(true);
   ok(!file.exists(), file.path + " should not exist");
--- a/toolkit/mozapps/update/tests/chrome/utils.js
+++ b/toolkit/mozapps/update/tests/chrome/utils.js
@@ -121,17 +121,17 @@ var gTimeoutTimer;
 // update window to close before giving up.
 const CLOSE_WINDOW_TIMEOUT_MAXCOUNT = 10;
 // Counter for the SimpleTest.executeSoon when waiting on an update window to
 // close before giving up.
 var gCloseWindowTimeoutCounter = 0;
 
 // The following vars are for restoring previous preference values (if present)
 // when the test finishes.
-var gAppUpdateEnabled; // app.update.enabled
+var gAppUpdateDisabled; // app.update.disabledForTesting
 var gAppUpdateServiceEnabled; // app.update.service.enabled
 var gAppUpdateStagingEnabled; // app.update.staging.enabled
 var gAppUpdateURLDefault; // app.update.url (default prefbranch)
 
 var gTestCounter = -1;
 var gWin;
 var gDocElem;
 var gPrefToCheck;
@@ -778,22 +778,22 @@ function setupPrefs() {
   // Prevent nsIUpdateTimerManager from notifying nsIApplicationUpdateService
   // to check for updates by setting the app update last update time to the
   // current time minus one minute in seconds and the interval time to 12 hours
   // in seconds.
   let now = Math.round(Date.now() / 1000) - 60;
   Services.prefs.setIntPref(PREF_APP_UPDATE_LASTUPDATETIME, now);
   Services.prefs.setIntPref(PREF_APP_UPDATE_INTERVAL, 43200);
 
-  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_ENABLED)) {
-    gAppUpdateEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED);
+  if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_DISABLEDFORTESTING)) {
+    gAppUpdateDisabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING);
   }
-  Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, true);
+  Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false);
 
-  if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO), false) {
+  if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO, false)) {
     Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO, true);
   }
 
   if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_SERVICE_ENABLED)) {
     gAppUpdateServiceEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED);
   }
   Services.prefs.setBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED, false);
 
@@ -845,20 +845,20 @@ function resetFiles() {
 /**
  * Resets the most common preferences used by tests to their original values.
  */
 function resetPrefs() {
   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 (gAppUpdateDisabled !== undefined) {
+    Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, gAppUpdateDisabled);
+  } else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_DISABLEDFORTESTING)) {
+    Services.prefs.clearUserPref(PREF_APP_UPDATE_DISABLEDFORTESTING);
   }
 
   if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_AUTO)) {
     Services.prefs.clearUserPref(PREF_APP_UPDATE_AUTO);
   }
 
   if (gAppUpdateServiceEnabled !== undefined) {
     Services.prefs.setBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED, gAppUpdateServiceEnabled);
--- a/toolkit/mozapps/update/tests/data/shared.js
+++ b/toolkit/mozapps/update/tests/data/shared.js
@@ -12,33 +12,34 @@ const PREF_APP_UPDATE_AUTO              
 const PREF_APP_UPDATE_BACKGROUNDERRORS           = "app.update.backgroundErrors";
 const PREF_APP_UPDATE_BACKGROUNDMAXERRORS        = "app.update.backgroundMaxErrors";
 const PREF_APP_UPDATE_CANCELATIONS               = "app.update.cancelations";
 const PREF_APP_UPDATE_CHANNEL                    = "app.update.channel";
 const PREF_APP_UPDATE_DOORHANGER                 = "app.update.doorhanger";
 const PREF_APP_UPDATE_DOWNLOADPROMPTATTEMPTS     = "app.update.download.attempts";
 const PREF_APP_UPDATE_DOWNLOADPROMPTMAXATTEMPTS  = "app.update.download.maxAttempts";
 const PREF_APP_UPDATE_DOWNLOADBACKGROUNDINTERVAL = "app.update.download.backgroundInterval";
-const PREF_APP_UPDATE_ENABLED                    = "app.update.enabled";
+const PREF_APP_UPDATE_DISABLEDFORTESTING         = "app.update.disabledForTesting";
 const PREF_APP_UPDATE_IDLETIME                   = "app.update.idletime";
 const PREF_APP_UPDATE_LOG                        = "app.update.log";
 const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED        = "app.update.notifiedUnsupported";
 const PREF_APP_UPDATE_PROMPTWAITTIME             = "app.update.promptWaitTime";
 const PREF_APP_UPDATE_RETRYTIMEOUT               = "app.update.socket.retryTimeout";
 const PREF_APP_UPDATE_SERVICE_ENABLED            = "app.update.service.enabled";
 const PREF_APP_UPDATE_SILENT                     = "app.update.silent";
 const PREF_APP_UPDATE_SOCKET_MAXERRORS           = "app.update.socket.maxErrors";
 const PREF_APP_UPDATE_STAGING_ENABLED            = "app.update.staging.enabled";
 const PREF_APP_UPDATE_URL                        = "app.update.url";
 const PREF_APP_UPDATE_URL_DETAILS                = "app.update.url.details";
 const PREF_APP_UPDATE_URL_MANUAL                 = "app.update.url.manual";
 
 const PREFBRANCH_APP_PARTNER         = "app.partner.";
 const PREF_DISTRIBUTION_ID           = "distribution.id";
 const PREF_DISTRIBUTION_VERSION      = "distribution.version";
+const PREF_DISABLE_SECURITY          = "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
 
 const NS_APP_PROFILE_DIR_STARTUP   = "ProfDS";
 const NS_APP_USER_PROFILE_50_DIR   = "ProfD";
 const NS_GRE_DIR                   = "GreD";
 const NS_GRE_BIN_DIR               = "GreBinD";
 const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD";
 const XRE_EXECUTABLE_FILE          = "XREExeF";
 const XRE_UPDATE_ROOT_DIR          = "UpdRootD";
--- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
+++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
@@ -1105,17 +1105,17 @@ function testFinishWaitForUpdateXMLFiles
 
   do_timeout(10, testFinishWaitForUpdateTmpXMLFiles);
 }
 
 /**
  * Sets the most commonly used preferences used by tests
  */
 function setDefaultPrefs() {
-  Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, true);
+  Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false);
   if (DEBUG_AUS_TEST) {
     // Enable Update logging
     Services.prefs.setBoolPref(PREF_APP_UPDATE_LOG, true);
   } else {
     // Some apps set this preference to true by default
     Services.prefs.setBoolPref(PREF_APP_UPDATE_LOG, false);
   }
 }