Part 10 - Bug 951662 - add ability to debug parallel test failures and declare gRegisteredServiceCleanup. r=bbondy
authorRobert Strong <robert.bugzilla@gmail.com>
Sun, 12 Jan 2014 13:47:12 -0800
changeset 179080 399d1a584acfaa952c75a8afe02b50b59880cdc1
parent 179079 6391c82f357d56186c449f4e8112477281e1b9bd
child 179081 7c4ed21fed281cda422b6a1176e36d7fb0098f4f
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs951662
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Part 10 - Bug 951662 - add ability to debug parallel test failures and declare gRegisteredServiceCleanup. r=bbondy
toolkit/mozapps/update/tests/sharedUpdateXML.js
toolkit/mozapps/update/tests/unit_aus_update/canCheckForAndCanApplyUpdates.js
toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForDifferentChannel.js
toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForOlderAppVersion.js
toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForSameVersionAndBuildID.js
toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingIncorrectStatus.js
toolkit/mozapps/update/tests/unit_aus_update/cleanupPendingVersionFileIncorrectStatus.js
toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js
toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js
toolkit/mozapps/update/tests/unit_aus_update/downloadAndHashCheckMar.js
toolkit/mozapps/update/tests/unit_aus_update/downloadCompleteAfterPartialFailure.js
toolkit/mozapps/update/tests/unit_aus_update/downloadFileTooBig_gonk.js
toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedByOfflineRetry.js
toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js
toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js
toolkit/mozapps/update/tests/unit_aus_update/head_update.js
toolkit/mozapps/update/tests/unit_aus_update/remoteUpdateXML.js
toolkit/mozapps/update/tests/unit_aus_update/uiOnlyAllowOneWindow.js
toolkit/mozapps/update/tests/unit_aus_update/uiSilentPref.js
toolkit/mozapps/update/tests/unit_aus_update/uiUnsupportedAlreadyNotified.js
toolkit/mozapps/update/tests/unit_aus_update/updateCheckOnLoadOnErrorStatusText.js
toolkit/mozapps/update/tests/unit_aus_update/updateManagerXML.js
toolkit/mozapps/update/tests/unit_aus_update/updateRootDirMigration_win.js
toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js
toolkit/mozapps/update/tests/unit_base_updater/marAppInUseFallbackStageFailureComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageFailureComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js
toolkit/mozapps/update/tests/unit_base_updater/marAppInUseSuccessComplete.js
toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessPartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessPartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js
toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailureComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailurePartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageSuccessComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageSuccessPartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailureComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailurePartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailureComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailurePartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageSuccessComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageSuccessPartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessComplete_win.js
toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessPartial_win.js
toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js
toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js
toolkit/mozapps/update/tests/unit_base_updater/marSuccessComplete.js
toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js
toolkit/mozapps/update/tests/unit_base_updater/marVersionDowngrade.js
toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js
toolkit/mozapps/update/tests/unit_service_updater/marAppInUseFallbackStageFailureCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marAppInUseStageFailureCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessPartialSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailureCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailurePartialSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageSuccessCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageSuccessPartialSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailureCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailurePartialSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailureCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailurePartialSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageSuccessCompleteSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageSuccessPartialSvc_win.js
toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js
toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js
--- a/toolkit/mozapps/update/tests/sharedUpdateXML.js
+++ b/toolkit/mozapps/update/tests/sharedUpdateXML.js
@@ -45,16 +45,22 @@ const STATE_PENDING         = "pending";
 const STATE_PENDING_SVC     = "pending-service";
 const STATE_APPLYING        = "applying";
 const STATE_APPLIED         = "applied";
 const STATE_APPLIED_SVC     = "applied-service";
 const STATE_SUCCEEDED       = "succeeded";
 const STATE_DOWNLOAD_FAILED = "download-failed";
 const STATE_FAILED          = "failed";
 
+const STATE_FAILED_READ_ERROR                      = STATE_FAILED + ": 6";
+const STATE_FAILED_WRITE_ERROR                     = STATE_FAILED + ": 7";
+const STATE_FAILED_CHANNEL_MISMATCH_ERROR          = STATE_FAILED + ": 22";
+const STATE_FAILED_VERSION_DOWNGRADE_ERROR         = STATE_FAILED + ": 23";
+const STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR = STATE_FAILED + ": 42";
+
 /**
  * Constructs a string representing a remote update xml file.
  *
  * @param  aUpdates
  *         The string representing the update elements.
  * @return The string representing a remote update xml file.
  */
 function getRemoteUpdatesXMLString(aUpdates) {
--- a/toolkit/mozapps/update/tests/unit_aus_update/canCheckForAndCanApplyUpdates.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/canCheckForAndCanApplyUpdates.js
@@ -18,10 +18,11 @@ function run_test() {
   standardInit();
 
   // Check if available updates can be checked for
   logTestInfo("testing nsIApplicationUpdateService:canCheckForUpdates");
   do_check_true(gAUS.canCheckForUpdates);
   // Check if updates can be applied
   logTestInfo("testing nsIApplicationUpdateService:canApplyUpdates");
   do_check_true(gAUS.canApplyUpdates);
-  do_test_finished();
+
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForDifferentChannel.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForDifferentChannel.js
@@ -35,10 +35,10 @@ function run_test() {
 
   do_check_eq(gUpdateManager.activeUpdate, null);
   // Verify that the active-update.xml file has had the update from the old
   // channel removed.
   file = getUpdatesXMLFile(true);
   logTestInfo("verifying contents of " + FILE_UPDATE_ACTIVE);
   do_check_eq(readFile(file), getLocalUpdatesXMLString(""));
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForOlderAppVersion.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForOlderAppVersion.js
@@ -27,10 +27,10 @@ function run_test() {
     // will remain active until the user chooses a new one, at
     // which point, the old update will be removed.
     do_check_neq(gUpdateManager.activeUpdate, null);
   } else {
     do_check_eq(gUpdateManager.activeUpdate, null);
   }
   do_check_eq(gUpdateManager.updateCount, 0);
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForSameVersionAndBuildID.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingForSameVersionAndBuildID.js
@@ -28,10 +28,10 @@ function run_test() {
     // will remain active until the user chooses a new one, at
     // which point, the old update will be removed.
     do_check_neq(gUpdateManager.activeUpdate, null);
   } else {
     do_check_eq(gUpdateManager.activeUpdate, null);
   }
   do_check_eq(gUpdateManager.updateCount, 0);
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingIncorrectStatus.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupDownloadingIncorrectStatus.js
@@ -28,10 +28,10 @@ function run_test() {
   logTestInfo("testing " + statusFile.path + " should not exist");
   do_check_false(statusFile.exists());
 
   logTestInfo("testing activeUpdate == null");
   do_check_eq(gUpdateManager.activeUpdate, null);
   logTestInfo("testing updateCount == 0");
   do_check_eq(gUpdateManager.updateCount, 0);
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupPendingVersionFileIncorrectStatus.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupPendingVersionFileIncorrectStatus.js
@@ -30,10 +30,10 @@ function run_test() {
   logTestInfo("testing " + dir.path + " should exist");
   do_check_true(dir.exists());
 
   var versionFile = dir.clone();
   versionFile.append(FILE_UPDATE_VERSION);
   logTestInfo("testing " + versionFile.path + " should not exist");
   do_check_false(versionFile.exists());
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js
@@ -38,10 +38,10 @@ function run_test() {
   log.append(FILE_BACKUP_LOG);
   logTestInfo("testing " + log.path + " shouldn't exist");
   do_check_false(log.exists());
 
   dir.append("0");
   logTestInfo("testing " + dir.path + " should exist (bug 512994)");
   do_check_true(dir.exists());
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js
@@ -49,10 +49,10 @@ function run_test() {
 
   logTestInfo("testing " + log.path + " contents (bug 470979)");
   do_check_eq(readFile(log), "Backup Update Log");
 
   dir.append("0");
   logTestInfo("testing " + dir.path + " should exist (bug 512994)");
   do_check_true(dir.exists());
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/downloadAndHashCheckMar.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadAndHashCheckMar.js
@@ -21,17 +21,17 @@ function run_test() {
   // The mock XMLHttpRequest is MUCH faster
   overrideXHR(callHandleEvent);
   standardInit();
   do_execute_soon(run_test_pt1);
 }
 
 // The HttpServer must be stopped before calling do_test_finished
 function finish_test() {
-  stop_httpserver(do_test_finished);
+  stop_httpserver(doTestFinish);
 }
 
 // Callback function used by the custom XMLHttpRequest implementation to
 // call the nsIDOMEventListener's handleEvent method for onload.
 function callHandleEvent() {
   gXHR.status = 400;
   gXHR.responseText = gResponseBody;
   try {
--- a/toolkit/mozapps/update/tests/unit_aus_update/downloadCompleteAfterPartialFailure.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadCompleteAfterPartialFailure.js
@@ -51,17 +51,18 @@ var WindowWatcher = {
     return {
       alert: function(aTitle, aText) {
         let title = getString("updaterIOErrorTitle");
         do_check_eq(aTitle, title);
         let text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg",
                                                       [Services.appinfo.name,
                                                        Services.appinfo.name], 2);
         do_check_eq(aText, text);
-        do_test_finished();
+
+        doTestFinish();
       }
     }; 
   },
 
   QueryInterface: function(iid) {
     if (iid.equals(AUS_Ci.nsIWindowWatcher) ||
         iid.equals(AUS_Ci.nsISupports))
       return this;
--- a/toolkit/mozapps/update/tests/unit_aus_update/downloadFileTooBig_gonk.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadFileTooBig_gonk.js
@@ -76,17 +76,18 @@ function check_test_pt1() {
   do_check_eq(gUpdateCount, 1);
 
   gActiveUpdate = gUpdates[0];
   do_check_neq(gActiveUpdate, null);
 
   let state = gAUS.downloadUpdate(gActiveUpdate, true);
   do_check_eq(state, "null");
   do_check_eq(gActiveUpdate.errorCode >>> 0 , AUS_Cr.NS_ERROR_FILE_TOO_BIG);
-  do_test_finished();
+
+  doTestFinish();
 }
 
 function end_test() {
   gDirService.unregisterProvider(gDirProvider);
   gDirService.registerProvider(gOldProvider);
   gActiveUpdate = null;
   gDirService = null;
   gDirProvider = null;
--- a/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedByOfflineRetry.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedByOfflineRetry.js
@@ -69,10 +69,10 @@ function xhr_pt2() {
   gXHR.onload({ target: gXHR });
 }
 
 function check_test_pt2(update) {
   // We just verify that there are updates to know the check succeeded.
   do_check_neq(update, null);
   do_check_eq(update.name, "App Update Test");
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js
@@ -28,17 +28,17 @@ function run_test() {
   // The mock XMLHttpRequest is MUCH faster
   overrideXHR(callHandleEvent);
   standardInit();
   do_execute_soon(run_test_pt1);
 }
 
 // The HttpServer must be stopped before calling do_test_finished
 function finish_test() {
-  stop_httpserver(do_test_finished);
+  stop_httpserver(doTestFinish);
 }
 
 function end_test() {
   cleanupMockIncrementalDownload();
 }
 
 // Callback function used by the custom XMLHttpRequest implementation to
 // call the nsIDOMEventListener's handleEvent method for onload.
--- a/toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js
@@ -33,10 +33,10 @@ function run_test() {
   // Pause the download and reload the Update Manager with an empty update so
   // the Application Update Service doesn't write the update xml files during
   // xpcom-shutdown which will leave behind the test directory.
   gAUS.pauseDownload();
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), true);
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   reloadUpdateManagerData();
 
-  do_timeout(TEST_CHECK_TIMEOUT, do_test_finished);
+  do_timeout(TEST_CHECK_TIMEOUT, doTestFinish);
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
@@ -115,17 +115,17 @@ const MAC_MAX_TIME_DIFFERENCE = 60000;
 
 // Time to wait for the test helper process before continuing the test
 const TEST_HELPER_TIMEOUT = 100;
 
 // Time to wait for a check in the test before continuing the test
 const TEST_CHECK_TIMEOUT = 100;
 
 // How many of TEST_CHECK_TIMEOUT to wait before we abort the test.
-const MAX_TIMEOUT_RUNS = 1000;
+const MAX_TIMEOUT_RUNS = 2000;
 
 // Maximum number of milliseconds the process that is launched can run before
 // the test will try to kill it.
 const APP_TIMER_TIMEOUT = 120000;
 
 #ifdef XP_WIN
 const PIPE_TO_NULL = "1> nul 2>&1";
 #else
@@ -134,16 +134,18 @@ const PIPE_TO_NULL = "> /dev/null 2>&1";
 
 // This default value will be overridden when using the http server.
 var gURLData = URL_HOST + "/";
 
 var gTestID;
 
 var gTestserver;
 
+var gRegisteredServiceCleanup;
+
 var gXHR;
 var gXHRCallback;
 
 var gUpdatePrompt;
 var gUpdatePromptCallback;
 
 var gCheckFunc;
 var gResponseBody;
@@ -341,16 +343,26 @@ var TEST_DIRS = [
 
 // Populated by tests if needed.
 var ADDITIONAL_TEST_DIRS = [];
 
 // Set to true to log additional information for debugging. To log additional
 // information for an individual test set DEBUG_AUS_TEST to true in the test's
 // run_test function.
 var DEBUG_AUS_TEST = true;
+// Never set DEBUG_TEST_LOG to true except when running tests locally or on the
+// try server since this will force a test that failed a parallel run to fail
+// when the same test runs non-parallel so the log from parallel test run can
+// be displayed in the log.
+var DEBUG_TEST_LOG = false;
+// Set to false to keep the log file from the failed parallel test run.
+var gDeleteLogFile = true;
+var gRealDump;
+var gTestLogText = "";
+var gPassed;
 
 #include ../shared.js
 
 #ifdef MOZ_MAINTENANCE_SERVICE
 const STATE_APPLIED_PLATFORM = STATE_APPLIED_SVC;
 #else
 const STATE_APPLIED_PLATFORM = STATE_APPLIED;
 #endif
@@ -369,22 +381,41 @@ if (MOZ_APP_NAME == "xulrunner") {
  * Helper function for setting up the test environment.
  */
 function setupTestCommon() {
   logTestInfo("start - general test setup");
 
   do_test_pending();
 
   if (gTestID) {
-    do_throw("should only be called once!");
+    do_throw("setupTestCommon should only be called once!");
   }
 
   let caller = Components.stack.caller;
   gTestID = caller.filename.toString().split("/").pop().split(".")[0];
 
+  if (DEBUG_TEST_LOG) {
+    let logFile = do_get_file(gTestID + ".log", true);
+    if (logFile.exists()) {
+      gPassed = false;
+      logTestInfo("start - dumping previous test run log");
+      logTestInfo("\n" + readFile(logFile) + "\n");
+      logTestInfo("finish - dumping previous test run log");
+      if (gDeleteLogFile) {
+        logFile.remove(false);
+      }
+      do_throw("The parallel run of this test failed. Failing non-parallel " +
+               "test so the log from the parallel run can be displayed in " +
+               "non-parallel log.")
+    } else {
+      gRealDump = dump;
+      dump = dumpOverride;
+    }
+  }
+
   // Don't attempt to show a prompt when an update finishes.
   Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true);
 
   gGREDirOrig = getGREDir();
   gAppDirOrig = getAppBaseDir();
 
   let applyDir = getApplyDirFile(null, true).parent;
   if (IS_MACOSX) {
@@ -527,16 +558,64 @@ function cleanupTestCommon() {
       logTestInfo("non-fatal error removing directory. Path: " +
                   applyDir.path + ", Exception: " + e);
     }
   }
 
   resetEnvironment();
 
   logTestInfo("finish - general test cleanup");
+
+  if (gRealDump) {
+    dump = gRealDump;
+    gRealDump = null;
+  }
+
+  if (DEBUG_TEST_LOG && !gPassed) {
+    let fos = AUS_Cc["@mozilla.org/network/file-output-stream;1"].
+              createInstance(AUS_Ci.nsIFileOutputStream);
+    let logFile = do_get_file(gTestID + ".log", true);
+    if (!logFile.exists()) {
+      logFile.create(AUS_Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
+    }
+    fos.init(logFile, MODE_WRONLY | MODE_CREATE | MODE_APPEND, PERMS_FILE, 0);
+    fos.write(gTestLogText, gTestLogText.length);
+    fos.close();
+  }
+
+  if (DEBUG_TEST_LOG) {
+    gTestLogText = null;
+  } else {
+    let logFile = do_get_file(gTestID + ".log", true);
+    if (logFile.exists()) {
+      logFile.remove(false);
+    }
+  }
+}
+
+/**
+ * Helper function to store the log output of calls to dump in a variable so the
+ * values can be written to a file for a parallel run of a test and printed to
+ * the log file when the test runs synchronously.
+ */
+function dumpOverride(aText) {
+  gTestLogText += aText;
+  gRealDump(aText);
+}
+
+/**
+ * Helper function that calls do_test_finished that tracks whether a parallel
+ * run of a test passed when it runs synchronously so the log output can be
+ * inspected.
+ */
+function doTestFinish() {
+  if (gPassed === undefined) {
+    gPassed = true;
+  }
+  do_test_finished();
 }
 
 /**
  * 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_METRO_ENABLED, true);
@@ -917,23 +996,25 @@ if (IS_WIN) {
 }
 
 /**
  * Helper function for updater tests for launching the updater binary to apply
  * a mar file.
  *
  * @param   aExpectedExitValue
  *          The expected exit value from the updater binary.
+ * @param   aExpectedStatus
+ *          The expected value of update.status when the test finishes.
  * @param   aCallback (optional)
  *          A callback function that will be called when this function finishes.
  *          If null no function will be called when this function finishes.
  *          If not specified the checkUpdateApplied function will be called when
  *          this function finishes.
  */
-function runUpdate(aExpectedExitValue, aCallback) {
+function runUpdate(aExpectedExitValue, aExpectedStatus, aCallback) {
   // Copy the updater binary to the updates directory.
   let binDir = gGREDirOrig.clone();
   let updater = binDir.clone();
   updater.append("updater.app");
   if (!updater.exists()) {
     updater = binDir.clone();
     updater.append(FILE_UPDATER_BIN);
     if (!updater.exists()) {
@@ -962,22 +1043,16 @@ function runUpdate(aExpectedExitValue, a
   if (IS_WIN) {
     // Convert to native path
     applyToDirPath = applyToDirPath.replace(/\//g, "\\");
   }
 
   let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile);
   callbackApp.permissions = PERMS_DIRECTORY;
 
-  // Backup the updater-settings.ini file if it exists by moving it.
-  let updateSettingsIni = getApplyDirFile(null, true);
-  updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
-  if (updateSettingsIni.exists()) {
-    updateSettingsIni.moveTo(updateSettingsIni.parent, FILE_UPDATE_SETTINGS_INI_BAK);
-  }
   updateSettingsIni = getApplyDirFile(null, true);
   updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
   writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
 
   let args = [updatesDir.path, applyToDirPath, 0];
   if (gStageUpdate) {
     args[2] = -1;
   } else {
@@ -999,26 +1074,36 @@ function runUpdate(aExpectedExitValue, a
                 createInstance(AUS_Ci.nsIProcess);
   process.init(updateBin);
   process.run(true, args, args.length);
 
   if (gDisableReplaceFallback) {
     env.set("MOZ_NO_REPLACE_FALLBACK", "");
   }
 
-  // Restore the backed up updater-settings.ini if it exists.
-  let updateSettingsIni = getApplyDirFile(null, true);
-  updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI_BAK);
-  if (updateSettingsIni.exists()) {
-    updateSettingsIni.moveTo(updateSettingsIni.parent, FILE_UPDATE_SETTINGS_INI);
+  let status = readStatusFile();
+  if (process.exitValue != aExpectedExitValue || status != aExpectedStatus) {
+    if (process.exitValue != aExpectedExitValue) {
+      logTestInfo("updater exited with unexpected value! Got: " +
+                  process.exitValue + ", Expected: " +  aExpectedExitValue);
+    }
+    if (status != aExpectedStatus) {
+      logTestInfo("update status is not the expected status! Got: " + status +
+                  ", Expected: " +  aExpectedStatus);
+    }
+    let updateLog = getUpdatesPatchDir();
+    updateLog.append(FILE_UPDATE_LOG);
+    logTestInfo("contents of " + updateLog.path + ":\n" +
+                readFileBytes(updateLog).replace(/\r\n/g, "\n"));
   }
-
   logTestInfo("testing updater binary process exitValue against expected " +
               "exit value");
   do_check_eq(process.exitValue, aExpectedExitValue);
+  logTestInfo("testing update status against expected status");
+  do_check_eq(status, aExpectedStatus);
 
   if (aCallback !== null) {
     if (typeof(aCallback) == typeof(Function)) {
       aCallback();
     } else {
       checkUpdateApplied();
     }
   }
@@ -1328,20 +1413,22 @@ function attemptServiceInstall() {
   logTestInfo("starting installer process...");
   installerProcess.run(true, [], 0);
 }
 
 /**
  * Helper function for updater tests for launching the updater using the
  * maintenance service to apply a mar file.
  *
- * @param aInitialStatus  the initial value of update.status.
- * @param aExpectedStatus the expected value of update.status when the test
-                          finishes.
- * @param aCheckSvcLog    whether the service log should be checked (optional).
+ * @param aInitialStatus
+ *        The initial value of update.status.
+ * @param aExpectedStatus
+ *        The expected value of update.status when the test finishes.
+ * @param aCheckSvcLog
+ *        Whether the service log should be checked (optional).
  */
 function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) {
   // Check the service logs for a successful update
   function checkServiceLogs(aOriginalContents) {
     let contents = readServiceLogFile();
     logTestInfo("the contents of maintenanceservice.log:\n" + contents + "\n");
     do_check_neq(contents, aOriginalContents);
     do_check_neq(contents.indexOf(LOG_SVC_SUCCESSFUL_LAUNCH), -1);
@@ -1411,17 +1498,17 @@ function runUpdateUsingService(aInitialS
                helperBinProcess.exitValue + ". Forcing test failure.");
     }
   }
 
   // Make sure the service from the previous test is already stopped.
   waitForServiceStop(true);
 
   // Prevent the cleanup function from begin run more than once
-  if (typeof(gRegisteredServiceCleanup) === "undefined") {
+  if (gRegisteredServiceCleanup === undefined) {
     gRegisteredServiceCleanup = true;
 
     do_register_cleanup(function RUUS_cleanup() {
       resetEnvironment();
 
       // This will delete the app arguments log file if it exists.
       try {
         getAppArgsLogPath();
@@ -1507,28 +1594,31 @@ function runUpdateUsingService(aInitialS
       logTestInfo("still waiting to see the " + aExpectedStatus +
                   " status, got " + status + " for now...");
       return;
     }
 
     // Make sure all of the logs are written out.
     waitForServiceStop(false);
 
-    // Restore the backed up updater-settings.ini if it exists.
-    let updateSettingsIni = getApplyDirFile(null, true);
-    updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI_BAK);
-    if (updateSettingsIni.exists()) {
-      updateSettingsIni.moveTo(updateSettingsIni.parent, FILE_UPDATE_SETTINGS_INI);
-    }
-
-    do_check_eq(status, aExpectedStatus);
-
     aTimer.cancel();
     aTimer = null;
 
+    if (status != aExpectedStatus) {
+      logTestInfo("update status is not the expected status! Got: " + status +
+                  ", Expected: " +  aExpectedStatus);
+      logTestInfo("update.status contents: " + readStatusFile());
+      let updateLog = getUpdatesPatchDir();
+      updateLog.append(FILE_UPDATE_LOG);
+      logTestInfo("contents of " + updateLog.path + ":\n" +
+                  readFileBytes(updateLog).replace(/\r\n/g, "\n"));
+    }
+    logTestInfo("testing update status against expected status");
+    do_check_eq(status, aExpectedStatus);
+
     if (aCheckSvcLog) {
       checkServiceLogs(svcOriginalLog);
     }
 
     checkUpdateFinished();
   }
 
   let timer = AUS_Cc["@mozilla.org/timer;1"].createInstance(AUS_Ci.nsITimer);
@@ -1562,24 +1652,40 @@ function getLaunchBin() {
   return launchBin;
 }
 
 /**
  * Helper function that waits until the helper has completed its operations and
  * is in a sleep state before performing an update by calling doUpdate.
  */
 function waitForHelperSleep() {
+  gTimeoutRuns++;
   // Give the lock file process time to lock the file before updating otherwise
   // this test can fail intermittently on Windows debug builds.
   let output = getApplyDirFile("a/b/output", true);
   if (readFile(output) != "sleeping\n") {
+    if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
+      do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the helper to " +
+               "finish its operation. Path: " + output.path);
+    }
     do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
     return;
   }
-  output.remove(false);
+  try {
+    output.remove(false);
+  }
+  catch (e) {
+    if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
+      do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the helper " +
+               "message file to no longer be in use. Path: " + output.path);
+    }
+    logTestInfo("failed to remove file. Path: " + output.path);
+    do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
+    return;
+  }
   doUpdate();
 }
 
 /**
  * Helper function that waits until the helper has finished its operations
  * before calling waitForHelperFinishFileUnlock to verify that the helper's
  * input and output directories are no longer in use.
  */
@@ -2099,18 +2205,18 @@ function waitForFilesInUse() {
           }
           do_timeout(TEST_CHECK_TIMEOUT, waitForFilesInUse);
           return;
         }
       }
     }
   }
 
-  logTestInfo("calling do_test_finished");
-  do_test_finished();
+  logTestInfo("calling doTestFinish");
+  doTestFinish();
 }
 
 /**
  * Helper function for updater binary tests for verifying there are no update
  * backup files left behind after an update.
  *
  * @param   aFile
  *          An nsIFile to check if it has moz-backup for its extension.
--- a/toolkit/mozapps/update/tests/unit_aus_update/remoteUpdateXML.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/remoteUpdateXML.js
@@ -315,10 +315,11 @@ function run_test_pt12() {
   run_test_helper_pt1("testing one update equal to the current version",
                       1, check_test_pt12);
 }
 
 function check_test_pt12() {
   var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
   do_check_neq(bestUpdate, null);
   do_check_eq(bestUpdate.displayVersion, "version 1.0");
-  do_test_finished();
+
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/uiOnlyAllowOneWindow.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/uiOnlyAllowOneWindow.js
@@ -53,17 +53,17 @@ function run_test() {
   do_check_true(true);
 
   let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
   registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
                               WindowWatcherFactory);
   registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
                               WindowMediatorFactory);
 
-  do_test_finished();
+  doTestFinish();
 }
 
 function check_showUpdateInstalled() {
   do_throw("showUpdateInstalled should not have called openWindow!");
 }
 
 function check_showUpdateAvailable() {
   do_throw("showUpdateAvailable should not have called openWindow!");
--- a/toolkit/mozapps/update/tests/unit_aus_update/uiSilentPref.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/uiSilentPref.js
@@ -56,17 +56,17 @@ function run_test() {
   // Report a successful check after the call to showUpdateError since it
   // didn't throw and otherwise it would report no tests run.
   do_check_true(true);
 
   let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
   registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
                               WindowWatcherFactory);
 
-  do_test_finished();
+  doTestFinish();
 }
 
 function check_showUpdateInstalled() {
   do_throw("showUpdateInstalled should not have called openWindow!");
 }
 
 function check_showUpdateAvailable() {
   do_throw("showUpdateAvailable should not have called openWindow!");
--- a/toolkit/mozapps/update/tests/unit_aus_update/uiUnsupportedAlreadyNotified.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/uiUnsupportedAlreadyNotified.js
@@ -43,17 +43,18 @@ function run_test() {
 }
 
 function check_test() {
   if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS)) {
     do_execute_soon(check_test);
     return;
   }
   do_check_true(true);
-  do_test_finished();
+
+  doTestFinish();
 }
 
 function end_test() {
   let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
   registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
                               WindowWatcherFactory);
   registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
                               WindowMediatorFactory);
--- a/toolkit/mozapps/update/tests/unit_aus_update/updateCheckOnLoadOnErrorStatusText.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/updateCheckOnLoadOnErrorStatusText.js
@@ -159,11 +159,11 @@ function run_test_pt15() {
 // network is offline - NS_ERROR_DOCUMENT_NOT_CACHED (2152398918)
 function run_test_pt16() {
   run_test_helper(run_test_pt17, AUS_Cr.NS_ERROR_DOCUMENT_NOT_CACHED,
                   "testing network is offline");
 }
 
 // connection refused - NS_ERROR_CONNECTION_REFUSED (2152398861)
 function run_test_pt17() {
-  run_test_helper(do_test_finished, AUS_Cr.NS_ERROR_CONNECTION_REFUSED,
+  run_test_helper(doTestFinish, AUS_Cr.NS_ERROR_CONNECTION_REFUSED,
                   "testing connection refused");
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/updateManagerXML.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/updateManagerXML.js
@@ -203,10 +203,10 @@ function run_test() {
   do_check_eq(patch.type, "complete");
   do_check_eq(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR);
   do_check_eq(patch.hashFunction, "MD5");
   do_check_eq(patch.hashValue, MD5_HASH_SIMPLE_MAR);
   do_check_eq(patch.size, SIZE_SIMPLE_MAR);
   do_check_true(patch.selected);
   do_check_eq(patch.state, STATE_FAILED);
 
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_aus_update/updateRootDirMigration_win.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/updateRootDirMigration_win.js
@@ -131,17 +131,17 @@ function run_test() {
       });
     } else {
       oldFile.append(relPath);
     }
     oldFile.create(AUS_Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
   });
   // Do the migration
   initUpdateServiceStub();
-  do_test_finished();
+  doTestFinish();
   return;
   // Now verify that each of the files exist in the new update directory
   filesToMigrate.forEach(relPath => {
     let newFile = newUpdateRoot.clone();
     let oldFile = oldUpdateRoot.clone();
     if (relPath instanceof Array) {
       relPath.forEach(relPathPart => {
         newFile.append(relPathPart);
@@ -154,17 +154,17 @@ function run_test() {
     // The file should be mimgrated, except for FILE_UPDATE_STATUS
     // which gets consumed by post update after it is migrated..
     if (newFile.leafName != FILE_UPDATE_STATUS) {
       do_check_true(newFile.exists());
     }
     do_check_false(oldFile.exists());
   });
 
-  do_test_finished();
+  doTestFinish();
 }
 
 function end_test() {
   var appinfo = AUS_Cc["@mozilla.org/xre/app-info;1"].
                 getService(AUS_Ci.nsIXULAppInfo).
                 QueryInterface(AUS_Ci.nsIXULRuntime);
   var exeFile = FileUtils.getFile(XRE_EXECUTABLE_FILE, []);
   clearTaskbarIDHash(exeFile.parent.path, appinfo.name);
--- a/toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js
@@ -399,10 +399,10 @@ function run_test_pt14() {
   var url = URL_PREFIX + "?custom=%CUSTOM%";
   logTestInfo("testing url constructed with %CUSTOM% - " + url);
   setUpdateURLOverride(url);
   gUpdateChecker.checkForUpdates(updateCheckListener, true);
 }
 
 function check_test_pt14() {
   do_check_eq(getResult(gRequestURL), "?custom=custom&force=1");
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseFallbackStageFailureComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseFallbackStageFailureComplete_win.js
@@ -193,34 +193,29 @@ function run_test() {
                            createInstance(AUS_Ci.nsIProcess);
   callbackAppProcess.init(callbackApp);
   callbackAppProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageFailureComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageFailureComplete_win.js
@@ -193,35 +193,30 @@ function run_test() {
                            createInstance(AUS_Ci.nsIProcess);
   callbackAppProcess.init(callbackApp);
   callbackAppProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js
@@ -250,41 +250,36 @@ function run_test() {
                            createInstance(AUS_Ci.nsIProcess);
   callbackAppProcess.init(callbackApp);
   callbackAppProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let applyToDir = getApplyDirFile(null, true);
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
 
   checkFilesAfterUpdateSuccess();
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   let applyToDir = getApplyDirFile();
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseSuccessComplete.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseSuccessComplete.js
@@ -250,27 +250,24 @@ function doUpdate() {
   // the past to test that the last modified time is updated on a successful
   // update (bug 600098).
   if (IS_MACOSX) {
     let now = Date.now();
     let yesterday = now - (1000 * 60 * 60 * 24);
     applyToDir.lastModifiedTime = yesterday;
   }
 
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let applyToDir = getApplyDirFile();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessComplete_win.js
@@ -189,30 +189,25 @@ ADDITIONAL_TEST_DIRS = [
 
 function run_test() {
   gStageUpdate = true;
   setupTestCommon();
   setupUpdaterTest(FILE_COMPLETE_WIN_MAR);
 
   gCallbackBinFile = "exe0.exe";
 
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessPartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppStageSuccessPartial_win.js
@@ -191,30 +191,25 @@ ADDITIONAL_TEST_DIRS = [
 
 function run_test() {
   gStageUpdate = true;
   setupTestCommon();
   setupUpdaterTest(FILE_PARTIAL_WIN_MAR);
 
   gCallbackBinFile = "exe0.exe";
 
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessComplete_win.js
@@ -189,23 +189,20 @@ ADDITIONAL_TEST_DIRS = [
 
 function run_test() {
   setupTestCommon();
 
   setupUpdaterTest(FILE_COMPLETE_WIN_MAR);
 
   gCallbackBinFile = "exe0.exe";
 
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessPartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marCallbackAppSuccessPartial_win.js
@@ -191,23 +191,20 @@ ADDITIONAL_TEST_DIRS = [
 
 function run_test() {
   setupTestCommon();
 
   setupUpdaterTest(FILE_PARTIAL_WIN_MAR);
 
   gCallbackBinFile = "exe0.exe";
 
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js
@@ -233,23 +233,20 @@ function run_test() {
   if (IS_MACOSX) {
     let now = Date.now();
     let yesterday = now - (1000 * 60 * 60 * 24);
     let applyToDir = getApplyDirFile();
     applyToDir.lastModifiedTime = yesterday;
   }
 
   // Note that on platforms where we use execv, we cannot trust the return code.
-  runUpdate((USE_EXECV ? 0 : 1));
+  runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let applyToDir = getApplyDirFile();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailureComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailureComplete_win.js
@@ -200,34 +200,29 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailurePartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseFallbackStageFailurePartial_win.js
@@ -202,34 +202,29 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageSuccessComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageSuccessComplete_win.js
@@ -200,35 +200,30 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageSuccessPartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseStageSuccessPartial_win.js
@@ -202,35 +202,30 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessComplete_win.js
@@ -199,27 +199,24 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
   checkUpdateLogContains(ERR_BACKUP_DISCARD);
 
   logTestInfo("testing tobedeleted directory exists");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_true(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileInUseSuccessPartial_win.js
@@ -201,27 +201,24 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
   checkUpdateLogContains(ERR_BACKUP_DISCARD);
 
   logTestInfo("testing tobedeleted directory exists");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_true(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailureComplete_win.js
@@ -200,27 +200,24 @@ function run_test() {
                      createInstance(AUS_Ci.nsIProcess);
   lockFileProcess.init(helperBin);
   lockFileProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure();
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFailurePartial_win.js
@@ -201,27 +201,24 @@ function run_test() {
                      createInstance(AUS_Ci.nsIProcess);
   lockFileProcess.init(helperBin);
   lockFileProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_READ_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure();
   checkUpdateLogContains(ERR_UNABLE_OPEN_DEST);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailureComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailureComplete_win.js
@@ -201,34 +201,29 @@ function run_test() {
                      createInstance(AUS_Ci.nsIProcess);
   lockFileProcess.init(helperBin);
   lockFileProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(1, null);
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailurePartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedFallbackStageFailurePartial_win.js
@@ -202,34 +202,29 @@ function run_test() {
                      createInstance(AUS_Ci.nsIProcess);
   lockFileProcess.init(helperBin);
   lockFileProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(1, null);
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailureComplete_win.js
@@ -201,35 +201,30 @@ function run_test() {
                      createInstance(AUS_Ci.nsIProcess);
   lockFileProcess.init(helperBin);
   lockFileProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(1, null);
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marFileLockedStageFailurePartial_win.js
@@ -202,35 +202,30 @@ function run_test() {
                      createInstance(AUS_Ci.nsIProcess);
   lockFileProcess.init(helperBin);
   lockFileProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(1, null);
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailureComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailureComplete_win.js
@@ -210,34 +210,29 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailurePartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseFallbackStageFailurePartial_win.js
@@ -210,34 +210,29 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageSuccessComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageSuccessComplete_win.js
@@ -210,35 +210,30 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageSuccessPartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseStageSuccessPartial_win.js
@@ -210,35 +210,30 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessComplete_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessComplete_win.js
@@ -209,27 +209,24 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
   checkUpdateLogContains(ERR_BACKUP_DISCARD);
 
   logTestInfo("testing tobedeleted directory exists");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_true(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessPartial_win.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marRMRFDirFileInUseSuccessPartial_win.js
@@ -209,27 +209,24 @@ function run_test() {
                          createInstance(AUS_Ci.nsIProcess);
   fileInUseProcess.init(fileInUseBin);
   fileInUseProcess.run(false, args, args.length);
 
   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
 }
 
 function doUpdate() {
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
   checkUpdateLogContains(ERR_BACKUP_DISCARD);
 
   logTestInfo("testing tobedeleted directory exists");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_true(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageFailurePartial.js
@@ -233,23 +233,20 @@ function run_test() {
   // the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
   if (IS_MACOSX) {
     let now = Date.now();
     let yesterday = now - (1000 * 60 * 60 * 24);
     let applyToDir = getApplyDirFile();
     applyToDir.lastModifiedTime = yesterday;
   }
 
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let applyToDir = getApplyDirFile();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
@@ -288,19 +288,17 @@ function run_test() {
       compareContents  : "test",
       originalFile     : null,
       compareFile      : null,
       originalPerms    : 0o664,
       comparePerms     : 0o664
     });
   }
 
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let applyToDir = getApplyDirFile();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
@@ -317,23 +315,20 @@ function run_test() {
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
   toBeDeletedDir = getTargetDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   let applyToDir = getApplyDirFile();
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessPartial.js
@@ -240,19 +240,17 @@ function run_test() {
   // the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
   if (IS_MACOSX) {
     let now = Date.now();
     let yesterday = now - (1000 * 60 * 60 * 24);
     let applyToDir = getApplyDirFile();
     applyToDir.lastModifiedTime = yesterday;
   }
 
-  runUpdate(0, null);
-  logTestInfo("testing update.status should be " + STATE_APPLIED);
-  do_check_eq(readStatusState(), STATE_APPLIED);
+  runUpdate(0, STATE_APPLIED, null);
 
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let applyToDir = getApplyDirFile();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
@@ -269,23 +267,20 @@ function run_test() {
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
   toBeDeletedDir = getTargetDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   let applyToDir = getApplyDirFile();
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessComplete.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessComplete.js
@@ -237,23 +237,20 @@ function run_test() {
   // update (bug 600098).
   if (IS_MACOSX) {
     let now = Date.now();
     let yesterday = now - (1000 * 60 * 60 * 24);
     let applyToDir = getApplyDirFile();
     applyToDir.lastModifiedTime = yesterday;
   }
 
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let applyToDir = getApplyDirFile();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartial.js
@@ -239,23 +239,20 @@ function run_test() {
   // the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
   if (IS_MACOSX) {
     let now = Date.now();
     let yesterday = now - (1000 * 60 * 60 * 24);
     let applyToDir = getApplyDirFile();
     applyToDir.lastModifiedTime = yesterday;
   }
 
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let applyToDir = getApplyDirFile();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marVersionDowngrade.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marVersionDowngrade.js
@@ -3,29 +3,27 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 /* Test version downgrade MAR security check */
 
 // We don't actually care if the MAR has any data, we only care about the
 // application return code and update.status result.
 const TEST_FILES = [];
-const VERSION_DOWNGRADE_ERROR = "23";
 
 function run_test() {
   if (!IS_MAR_CHECKS_ENABLED) {
     return;
   }
 
   setupTestCommon();
   setupUpdaterTest(FILE_OLD_VERSION_MAR);
 
   // Apply the MAR
   // Note that if execv is used, the updater process will turn into the
   // callback process, so its return code will be that of the callback
   // app.
-  runUpdate((USE_EXECV ? 0 : 1));
+  runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_VERSION_DOWNGRADE_ERROR);
 }
 
 function checkUpdateApplied() {
-  do_check_eq(readStatusFailedCode(), VERSION_DOWNGRADE_ERROR);
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marWrongChannel.js
@@ -3,30 +3,27 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 /* Test product/channel MAR security check */
 
 // We don't actually care if the MAR has any data, we only care about the
 // application return code and update.status result.
 const TEST_FILES = [];
-const MAR_CHANNEL_MISMATCH_ERROR = "22";
 
 function run_test() {
   if (!IS_MAR_CHECKS_ENABLED) {
     return;
   }
 
   setupTestCommon();
   setupUpdaterTest(FILE_WRONG_CHANNEL_MAR);
 
   // Apply the MAR
   // Note that if execv is used, the updater process will turn into the
   // callback process, so its return code will be that of the callback
   // app.
-  runUpdate((USE_EXECV ? 0 : 1));
+  runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_CHANNEL_MISMATCH_ERROR);
 }
 
 function checkUpdateApplied() {
-  //Make sure we get a version downgrade error
-  do_check_eq(readStatusFailedCode(), MAR_CHANNEL_MISMATCH_ERROR);
-  do_test_finished();
+  doTestFinish();
 }
--- a/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseFallbackStageFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseFallbackStageFailureCompleteSvc_win.js
@@ -211,27 +211,24 @@ function doUpdate() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseStageFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marAppInUseStageFailureCompleteSvc_win.js
@@ -212,27 +212,24 @@ function doUpdate() {
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessCompleteSvc_win.js
@@ -207,23 +207,20 @@ function setupAppFilesFinished() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
--- a/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessPartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marCallbackAppStageSuccessPartialSvc_win.js
@@ -209,23 +209,20 @@ function setupAppFilesFinished() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailureCompleteSvc_win.js
@@ -218,27 +218,24 @@ function doUpdate() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailurePartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseFallbackStageFailurePartialSvc_win.js
@@ -220,27 +220,24 @@ function doUpdate() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageSuccessCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageSuccessCompleteSvc_win.js
@@ -219,27 +219,24 @@ function doUpdate() {
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageSuccessPartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileInUseStageSuccessPartialSvc_win.js
@@ -221,27 +221,24 @@ function doUpdate() {
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailureCompleteSvc_win.js
@@ -219,27 +219,24 @@ function doUpdate() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_FAILED);
   do_check_eq(readStatusState(), STATE_FAILED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailurePartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFallbackStageFailurePartialSvc_win.js
@@ -220,27 +220,24 @@ function doUpdate() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_FAILED);
   do_check_eq(readStatusState(), STATE_FAILED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailureCompleteSvc_win.js
@@ -220,27 +220,24 @@ function doUpdate() {
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_FAILED);
   do_check_eq(readStatusState(), STATE_FAILED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedStageFailurePartialSvc_win.js
@@ -221,27 +221,24 @@ function doUpdate() {
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_FAILED);
   do_check_eq(readStatusState(), STATE_FAILED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailureCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailureCompleteSvc_win.js
@@ -228,27 +228,24 @@ function doUpdate() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailurePartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseFallbackStageFailurePartialSvc_win.js
@@ -228,27 +228,24 @@ function doUpdate() {
 
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(1);
+  runUpdate(1, STATE_PENDING);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_PENDING);
-  do_check_eq(readStatusState(), STATE_PENDING);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageSuccessCompleteSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageSuccessCompleteSvc_win.js
@@ -229,27 +229,24 @@ function doUpdate() {
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageSuccessPartialSvc_win.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseStageSuccessPartialSvc_win.js
@@ -229,27 +229,24 @@ function doUpdate() {
 function checkUpdateFinished() {
   logTestInfo("testing update.status should be " + STATE_APPLIED);
   do_check_eq(readStatusState(), STATE_APPLIED);
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
   gDisableReplaceFallback = true;
-  runUpdate(1);
+  runUpdate(1, STATE_FAILED_WRITE_ERROR);
 }
 
 function checkUpdateApplied() {
   setupHelperFinish();
 }
 
 function checkUpdate() {
-  logTestInfo("testing update.status should be " + STATE_FAILED);
-  do_check_eq(readStatusState(), STATE_FAILED);
-
   checkFilesAfterUpdateFailure(getApplyDirFile);
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
--- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js
@@ -328,23 +328,20 @@ function checkUpdateFinished() {
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
   toBeDeletedDir = getTargetDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   let applyToDir = getApplyDirFile();
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }
--- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessPartialSvc.js
@@ -280,23 +280,20 @@ function checkUpdateFinished() {
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
   toBeDeletedDir = getTargetDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   // Now switch the application and its updated version.
   gStageUpdate = false;
   gSwitchApp = true;
-  runUpdate(0);
+  runUpdate(0, STATE_SUCCEEDED);
 }
 
 function checkUpdateApplied() {
-  logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
-  do_check_eq(readStatusState(), STATE_SUCCEEDED);
-
   let applyToDir = getApplyDirFile();
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
     let now = Date.now();
     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
   }