Bug 879612 - Move app update common xpcshell test code into head_update.js.in. r=bbondy
authorRobert Strong <robert.bugzilla@gmail.com>
Mon, 30 Sep 2013 14:54:38 -0700
changeset 163161 34afd6c4cd9b44f03ab767b010d955a1e7668b66
parent 163160 2fa72efe5bd3579e65bd452c6bee8aa41c47743a
child 163162 78fb1730c9d3b7925bd1f54aff6c54ea94d3baf1
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs879612
milestone27.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
Bug 879612 - Move app update common xpcshell test code into head_update.js.in. r=bbondy
toolkit/mozapps/update/test/unit/head_update.js.in
toolkit/mozapps/update/test/unit/test_0010_general.js
toolkit/mozapps/update/test/unit/test_0020_general.js
toolkit/mozapps/update/test/unit/test_0030_general.js
toolkit/mozapps/update/test/unit/test_0040_general.js
toolkit/mozapps/update/test/unit/test_0050_general.js
toolkit/mozapps/update/test/unit/test_0060_manager.js
toolkit/mozapps/update/test/unit/test_0061_manager.js
toolkit/mozapps/update/test/unit/test_0062_manager.js
toolkit/mozapps/update/test/unit/test_0063_manager.js
toolkit/mozapps/update/test/unit/test_0064_manager.js
toolkit/mozapps/update/test/unit/test_0070_update_dir_cleanup.js
toolkit/mozapps/update/test/unit/test_0071_update_dir_cleanup.js
toolkit/mozapps/update/test/unit/test_0072_update_dir_cleanup.js
toolkit/mozapps/update/test/unit/test_0073_update_dir_cleanup.js
toolkit/mozapps/update/test/unit/test_0080_prompt_silent.js
toolkit/mozapps/update/test/unit/test_0081_prompt_uiAlreadyOpen.js
toolkit/mozapps/update/test/unit/test_0082_prompt_unsupportAlreadyNotified.js
toolkit/mozapps/update/test/unit/test_0110_general.js
toolkit/mozapps/update/test/unit/test_0111_general.js
toolkit/mozapps/update/test/unit/test_0112_general.js
toolkit/mozapps/update/test/unit/test_0113_general.js
toolkit/mozapps/update/test/unit/test_0113_versionDowngradeCheck.js
toolkit/mozapps/update/test/unit/test_0114_general.js
toolkit/mozapps/update/test/unit/test_0114_productChannelCheck.js
toolkit/mozapps/update/test/unit/test_0115_general.js
toolkit/mozapps/update/test/unit/test_0150_appBinReplaced_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0151_appBinPatched_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0152_appBinReplaced_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0153_appBinPatched_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0160_appInUse_complete.js
toolkit/mozapps/update/test/unit/test_0161_appInUse_xp_unix_complete.js
toolkit/mozapps/update/test/unit/test_0161_appInUse_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0162_appInUse_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0170_fileLocked_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0171_fileLocked_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0172_fileLocked_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0173_fileLocked_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0174_fileLocked_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0175_fileLocked_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0180_fileInUse_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0181_fileInUse_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0182_rmrfdirFileInUse_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0183_rmrfdirFileInUse_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0184_fileInUse_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0185_fileInUse_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0186_rmrfdirFileInUse_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0187_rmrfdirFileInUse_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0188_fileInUse_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0189_fileInUse_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_0190_rmrfdirFileInUse_xp_win_complete.js
toolkit/mozapps/update/test/unit/test_0191_rmrfdirFileInUse_xp_win_partial.js
toolkit/mozapps/update/test/unit/test_bug595059.js
toolkit/mozapps/update/test/unit/test_bug794211.js
toolkit/mozapps/update/test/unit/test_bug833708.js
--- a/toolkit/mozapps/update/test/unit/head_update.js.in
+++ b/toolkit/mozapps/update/test/unit/head_update.js.in
@@ -1159,26 +1159,16 @@ function setupUpdaterTest(aMarFile) {
       }
     }
   });
 
   let helperBin = do_get_file(HELPER_BIN_FILE);
   let afterApplyBinDir = getApplyDirFile("a/b/", true);
   helperBin.copyTo(afterApplyBinDir, gCallbackBinFile);
 
-  if (!gBackgroundUpdate && !gSwitchApp) {
-    let updaterIniContents = "[Strings]\n" +
-                             "Title=Update XPCShell Test\n" +
-                             "Info=Application Update Test - " + TEST_ID + "\n";
-    let updaterIni = updatesDir.clone();
-    updaterIni.append(FILE_UPDATER_INI);
-    writeFile(updaterIni, updaterIniContents);
-    updaterIni.copyTo(afterApplyBinDir, FILE_UPDATER_INI);
-  }
-
   // Copy the mar that will be applied
   let mar = do_get_file(aMarFile);
   mar.copyTo(updatesDir, FILE_UPDATE_ARCHIVE);
 
   // Add the test directory that will be updated for a successful update or left in
   // the initial state for a failed update.
   var testDirs = TEST_DIRS.concat(ADDITIONAL_TEST_DIRS);
   testDirs.forEach(function SUT_TD_FE(aTestDir) {
@@ -2235,16 +2225,18 @@ function adjustGeneralPaths() {
           iid.equals(AUS_Ci.nsISupports))
         return this;
       throw AUS_Cr.NS_ERROR_NO_INTERFACE;
     }
   };
   let ds = Services.dirsvc.QueryInterface(AUS_Ci.nsIDirectoryService);
   ds.registerProvider(dirProvider);
   do_register_cleanup(function() {
+    // Call end_test first before the directory provider is unregistered
+    end_test();
     ds.unregisterProvider(dirProvider);
     let testBin = do_get_file(getApplyDirPath() + "test" + APP_BIN_SUFFIX, true);
     // Try to remove the test.bin file if it exists (it shouldn't).
     if (testBin.exists()) {
       try {
         testBin.remove(false);
       }
       catch (e) {
--- a/toolkit/mozapps/update/test/unit/test_0010_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0010_general.js
@@ -4,18 +4,18 @@
  */
 
 /* General Update Service Tests */
 
 const TEST_ID = "0010";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   // Verify write access to the custom app dir
   logTestInfo("testing write access to the application directory");
   removeUpdateDirsAndFiles();
   var testFile = getCurrentProcessDir();
   testFile.append("update_write_access_test");
   testFile.create(AUS_Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
--- a/toolkit/mozapps/update/test/unit/test_0020_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0020_general.js
@@ -7,18 +7,18 @@
 
 const TEST_ID = "0020";
 
 var gNextRunFunc;
 var gExpectedCount;
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
   setUpdateURLOverride();
   setUpdateChannel("test_channel");
   // The mock XMLHttpRequest is MUCH faster
   overrideXHR(callHandleEvent);
   standardInit();
--- a/toolkit/mozapps/update/test/unit/test_0030_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0030_general.js
@@ -18,18 +18,18 @@ var gExpectedStatusResult;
 var gIncrementalDownloadClassID, gIncOldFactory;
 
 // gIncrementalDownloadErrorType is used to loop through each of the connection
 // error types in the Mock incremental downloader.
 var gIncrementalDownloadErrorType = 0;
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   Services.prefs.setBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, false);
   removeUpdateDirsAndFiles();
   setUpdateURLOverride();
   // The mock XMLHttpRequest is MUCH faster
   overrideXHR(callHandleEvent);
   standardInit();
--- a/toolkit/mozapps/update/test/unit/test_0040_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0040_general.js
@@ -10,18 +10,18 @@ Components.utils.import("resource://gre/
 const TEST_ID = "0040";
 
 const URL_PREFIX = URL_HOST + URL_PATH + "/";
 
 var gAppInfo;
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
   // The mock XMLHttpRequest is MUCH faster
   overrideXHR(callHandleEvent);
   standardInit();
   gAppInfo = AUS_Cc["@mozilla.org/xre/app-info;1"].
              getService(AUS_Ci.nsIXULAppInfo).
--- a/toolkit/mozapps/update/test/unit/test_0050_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0050_general.js
@@ -14,18 +14,18 @@
 const TEST_ID = "0050";
 
 var gNextRunFunc;
 var gExpectedStatusCode;
 var gExpectedStatusText;
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
   setUpdateURLOverride();
   standardInit();
   // The mock XMLHttpRequest is MUCH faster
   overrideXHR(callHandleEvent);
   do_execute_soon(run_test_pt1);
--- a/toolkit/mozapps/update/test/unit/test_0060_manager.js
+++ b/toolkit/mozapps/update/test/unit/test_0060_manager.js
@@ -4,18 +4,18 @@
  */
 
 /* General Update Manager Tests */
 
 const TEST_ID = "0060";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("testing addition of a successful update to " + FILE_UPDATES_DB +
               " and verification of update properties with the format prior " +
               "to bug 530872");
   removeUpdateDirsAndFiles();
   setUpdateChannel("test_channel");
 
--- a/toolkit/mozapps/update/test/unit/test_0061_manager.js
+++ b/toolkit/mozapps/update/test/unit/test_0061_manager.js
@@ -4,18 +4,18 @@
  */
 
 /* General Update Manager Tests */
 
 const TEST_ID = "0061";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("testing removal of an update download in progress for an " +
               "older version of the application on startup (bug 485624)");
   removeUpdateDirsAndFiles();
 
   var patches, updates;
 
--- a/toolkit/mozapps/update/test/unit/test_0062_manager.js
+++ b/toolkit/mozapps/update/test/unit/test_0062_manager.js
@@ -4,18 +4,18 @@
  */
 
 /* General Update Manager Tests */
 
 const TEST_ID = "0062";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("testing resuming an update download in progress for the same " +
               "version of the application on startup (bug 485624)");
   removeUpdateDirsAndFiles();
 
   var patches, updates;
 
--- a/toolkit/mozapps/update/test/unit/test_0063_manager.js
+++ b/toolkit/mozapps/update/test/unit/test_0063_manager.js
@@ -4,18 +4,18 @@
  */
 
 /* General Update Manager Tests */
 
 const TEST_ID = "0063";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("testing removing an active update for a channel that is not" +
               "valid due to switching channels (bug 486275)");
   removeUpdateDirsAndFiles();
 
   var patches, updates, update;
 
--- a/toolkit/mozapps/update/test/unit/test_0064_manager.js
+++ b/toolkit/mozapps/update/test/unit/test_0064_manager.js
@@ -4,18 +4,18 @@
  */
 
 /* General Update Manager Tests */
 
 const TEST_ID = "0064";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("testing removal of an update download in progress for the " +
               "same version of the application with the same application " +
               "build id on startup (bug 536547)");
   removeUpdateDirsAndFiles();
 
   var patches, updates;
--- a/toolkit/mozapps/update/test/unit/test_0070_update_dir_cleanup.js
+++ b/toolkit/mozapps/update/test/unit/test_0070_update_dir_cleanup.js
@@ -4,18 +4,18 @@
  */
 
 /* General Update Directory Cleanup Tests */
 
 const TEST_ID = "0070";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   var patches = getLocalPatchString(null, null, null, null, null, null,
                                     STATE_PENDING);
   var updates = getLocalUpdateString(patches);
--- a/toolkit/mozapps/update/test/unit/test_0071_update_dir_cleanup.js
+++ b/toolkit/mozapps/update/test/unit/test_0071_update_dir_cleanup.js
@@ -4,18 +4,18 @@
  */
 
 /* General Update Directory Cleanup Tests */
 
 const TEST_ID = "0071";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   var patches = getLocalPatchString(null, null, null, null, null, null,
                                     STATE_PENDING);
   var updates = getLocalUpdateString(patches);
--- a/toolkit/mozapps/update/test/unit/test_0072_update_dir_cleanup.js
+++ b/toolkit/mozapps/update/test/unit/test_0072_update_dir_cleanup.js
@@ -3,18 +3,18 @@
  */
 
 /* General Update Directory Cleanup Tests - Bug 539717 */
 
 const TEST_ID = "0072";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   var patches = getLocalPatchString(null, null, null, null, null, null,
                                     STATE_DOWNLOADING);
   var updates = getLocalUpdateString(patches);
--- a/toolkit/mozapps/update/test/unit/test_0073_update_dir_cleanup.js
+++ b/toolkit/mozapps/update/test/unit/test_0073_update_dir_cleanup.js
@@ -3,18 +3,18 @@
  */
 
 /* General Update Directory Cleanup Tests - Bug 601701 */
 
 const TEST_ID = "0073";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   var patches = getLocalPatchString(null, null, null, null, null, null,
                                     STATE_PENDING);
   var updates = getLocalUpdateString(patches);
--- a/toolkit/mozapps/update/test/unit/test_0080_prompt_silent.js
+++ b/toolkit/mozapps/update/test/unit/test_0080_prompt_silent.js
@@ -7,18 +7,18 @@
  * showUpdateAvailable, and showUpdateError when the app.update.silent
  * preference is true.
  */
 
 const TEST_ID = "0080";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("testing nsIUpdatePrompt notifications should not be seen " +
               "when the " + PREF_APP_UPDATE_SILENT + " preference is true");
 
   removeUpdateDirsAndFiles();
 
   Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true);
--- a/toolkit/mozapps/update/test/unit/test_0081_prompt_uiAlreadyOpen.js
+++ b/toolkit/mozapps/update/test/unit/test_0081_prompt_uiAlreadyOpen.js
@@ -6,18 +6,18 @@
  * Test that nsIUpdatePrompt doesn't display UI for showUpdateInstalled and
  * showUpdateAvailable when there is already an application update window open.
  */
 
 const TEST_ID = "0081";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("testing nsIUpdatePrompt notifications should not be seen when " +
               "there is already an application update window open");
 
   removeUpdateDirsAndFiles();
 
   Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
--- a/toolkit/mozapps/update/test/unit/test_0082_prompt_unsupportAlreadyNotified.js
+++ b/toolkit/mozapps/update/test/unit/test_0082_prompt_unsupportAlreadyNotified.js
@@ -6,18 +6,18 @@
  * Test that nsIUpdatePrompt doesn't display UI for showUpdateAvailable for an
  * unsupported system update when it has already been shown (bug 843497).
  */
 
 const TEST_ID = "0082";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
   setUpdateURLOverride();
   // The mock XMLHttpRequest is MUCH faster
   overrideXHR(callHandleEvent);
   standardInit();
   // The HTTP server is only used for the mar file downloads which is slow
--- a/toolkit/mozapps/update/test/unit/test_0110_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0110_general.js
@@ -231,18 +231,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
   let applyToDir = getApplyDirFile();
 
   // For Mac OS X set the last modified time for the root directory to a date in
@@ -281,8 +281,12 @@ function run_test() {
   }
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0111_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0111_general.js
@@ -233,18 +233,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_PARTIAL_FILE);
 
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
   let applyToDir = getApplyDirFile();
 
   // For Mac OS X set the last modified time for the root directory to a date in
@@ -282,8 +282,12 @@ function run_test() {
   }
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0112_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0112_general.js
@@ -226,18 +226,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_PARTIAL_FILE);
 
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
   let applyToDir = getApplyDirFile();
 
   // For Mac OS X set the last modified time for the root directory to a date in
@@ -278,8 +278,12 @@ function run_test() {
   }
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0113_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0113_general.js
@@ -264,18 +264,18 @@ function removeSymlink() {
 
 function checkSymlink() {
   let args = ["check-symlink", getApplyDirFile().path + "/a/b/link"];
   runHelperProcess(args);
 }
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
   let applyToDir = getApplyDirFile();
 
@@ -378,8 +378,12 @@ function run_test() {
 
   // Make sure that the intermediate directory has been removed
   let updatedDir = applyToDir.clone();
   updatedDir.append(UPDATED_DIR_SUFFIX.replace("/", ""));
   do_check_false(updatedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0113_versionDowngradeCheck.js
+++ b/toolkit/mozapps/update/test/unit/test_0113_versionDowngradeCheck.js
@@ -13,21 +13,20 @@ const TEST_FILES = [];
 
 const VERSION_DOWNGRADE_ERROR = "23";
 
 function run_test() {
   if (!IS_MAR_CHECKS_ENABLED) {
     return;
   }
 
-  // Setup an old version MAR file
-  do_register_cleanup(cleanupUpdaterTest);
-
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
+  // Setup an old version MAR file
   setupUpdaterTest(MAR_OLD_VERSION_FILE);
 
   // Apply the MAR
   let exitValue = runUpdate();
   logTestInfo("testing updater binary process exitValue for failure when " +
               "applying a version downgrade MAR");
   // Make sure the updater execution failed.
   // Note that if execv is used, the updater process will turn into the
@@ -35,8 +34,12 @@ function run_test() {
   // app.
   do_check_eq(exitValue, USE_EXECV ? 0 : 1);
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
 
   //Make sure we get a version downgrade error
   let updateStatus = readStatusFile(updatesDir);
   do_check_eq(updateStatus.split(": ")[1], VERSION_DOWNGRADE_ERROR);
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0114_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0114_general.js
@@ -233,18 +233,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_PARTIAL_FILE);
 
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
   let applyToDir = getApplyDirFile();
 
@@ -323,8 +323,12 @@ function run_test() {
 
   // Make sure that the intermediate directory has been removed
   let updatedDir = applyToDir.clone();
   updatedDir.append(UPDATED_DIR_SUFFIX.replace("/", ""));
   do_check_false(updatedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0114_productChannelCheck.js
+++ b/toolkit/mozapps/update/test/unit/test_0114_productChannelCheck.js
@@ -13,20 +13,20 @@ const TEST_FILES = [];
 
 const MAR_CHANNEL_MISMATCH_ERROR = "22";
 
 function run_test() {
   if (!IS_MAR_CHECKS_ENABLED) {
     return;
   }
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   // Setup a wrong channel MAR file
-  do_register_cleanup(cleanupUpdaterTest);
   setupUpdaterTest(MAR_WRONG_CHANNEL_FILE);
 
   // Apply the MAR
   let exitValue = runUpdate();
   logTestInfo("testing updater binary process exitValue for failure when " +
               "applying a wrong product and channel MAR file");
   // Make sure the updater execution failed.
   // Note that if execv is used, the updater process will turn into the
@@ -34,8 +34,12 @@ function run_test() {
   // app.
   do_check_eq(exitValue, USE_EXECV ? 0 : 1);
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
 
   //Make sure we get a version downgrade error
   let updateStatus = readStatusFile(updatesDir);
   do_check_eq(updateStatus.split(": ")[1], MAR_CHANNEL_MISMATCH_ERROR);
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0115_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0115_general.js
@@ -225,18 +225,19 @@ ADDITIONAL_TEST_DIRS = [
   dirRemoved   : false
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : false
 }];
 
 function run_test() {
-  do_register_cleanup(cleanupUpdaterTest);
+  do_test_pending();
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_PARTIAL_FILE);
 
   let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
   let applyToDir = getApplyDirFile();
 
@@ -277,9 +278,15 @@ function run_test() {
   }
 
   // This shouldn't exist anyways in background updates, but let's make sure
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
   toBeDeletedDir = getTargetDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
+
+  do_test_finished();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0150_appBinReplaced_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0150_appBinReplaced_xp_win_complete.js
@@ -187,18 +187,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_COMPLETE_WIN_FILE);
 
   gCallbackBinFile = "exe0.exe";
 
   // apply the complete mar
   let exitValue = runUpdate();
@@ -213,8 +213,12 @@ function run_test() {
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0151_appBinPatched_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0151_appBinPatched_xp_win_partial.js
@@ -189,18 +189,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_IN_USE_WIN_FILE);
 
   gCallbackBinFile = "exe0.exe";
 
   // apply the complete mar
   let exitValue = runUpdate();
@@ -215,8 +215,12 @@ function run_test() {
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0152_appBinReplaced_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0152_appBinReplaced_xp_win_complete.js
@@ -187,18 +187,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_WIN_FILE);
 
   gCallbackBinFile = "exe0.exe";
 
   // apply the complete mar
@@ -225,8 +225,12 @@ function run_test() {
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0153_appBinPatched_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0153_appBinPatched_xp_win_partial.js
@@ -189,18 +189,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_IN_USE_WIN_FILE);
 
   gCallbackBinFile = "exe0.exe";
 
   // apply the complete mar
@@ -227,8 +227,12 @@ function run_test() {
   checkFilesAfterUpdateSuccess();
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0160_appInUse_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0160_appInUse_complete.js
@@ -230,18 +230,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Launch the callback helper application so it is in use during the update
   let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile);
   callbackApp.permissions = PERMS_DIRECTORY;
   let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", "20"];
@@ -296,8 +296,13 @@ function checkUpdate() {
   if (IS_WIN) {
     logTestInfo("testing tobedeleted directory doesn't exist");
     let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
     do_check_false(toBeDeletedDir.exists());
   }
 
   checkCallbackAppLog();
 }
+
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0161_appInUse_xp_unix_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0161_appInUse_xp_unix_complete.js
@@ -230,18 +230,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   let applyToDir = getApplyDirFile();
 
   // For Mac OS X set the last modified time for the root directory to a date in
@@ -323,8 +323,13 @@ function doUpdate() {
 
   setupHelperFinish();
 }
 
 
 function checkUpdate() {
   checkCallbackAppLog();
 }
+
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0161_appInUse_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0161_appInUse_xp_win_complete.js
@@ -180,18 +180,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Launch the callback helper application so it is in use during the update
   let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile);
   let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", "40"];
@@ -237,8 +237,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0162_appInUse_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0162_appInUse_xp_win_complete.js
@@ -180,18 +180,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Launch the callback helper application so it is in use during the update
   let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile);
   let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", "40"];
@@ -234,8 +234,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0170_fileLocked_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0170_fileLocked_xp_win_complete.js
@@ -180,18 +180,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Exclusively lock an existing file so it is in use during the update
   let helperBin = do_get_file(HELPER_BIN_FILE);
   let helperDestDir = getApplyDirFile("a/b/");
   helperBin.copyTo(helperDestDir, HELPER_BIN_FILE);
@@ -231,8 +231,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0171_fileLocked_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0171_fileLocked_xp_win_partial.js
@@ -181,18 +181,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_PARTIAL_FILE);
 
   // Exclusively lock an existing file so it is in use during the update
   let helperBin = do_get_file(HELPER_BIN_FILE);
   let helperDestDir = getApplyDirFile("a/b/");
   helperBin.copyTo(helperDestDir, HELPER_BIN_FILE);
@@ -232,8 +232,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_UNABLE_OPEN_DEST);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0172_fileLocked_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0172_fileLocked_xp_win_complete.js
@@ -180,18 +180,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Exclusively lock an existing file so it is in use during the update
   let helperBin = do_get_file(HELPER_BIN_FILE);
   let helperDestDir = getApplyDirFile("a/b/");
@@ -245,8 +245,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0173_fileLocked_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0173_fileLocked_xp_win_partial.js
@@ -181,18 +181,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_PARTIAL_FILE);
 
   // Exclusively lock an existing file so it is in use during the update
   let helperBin = do_get_file(HELPER_BIN_FILE);
   let helperDestDir = getApplyDirFile("a/b/");
@@ -246,8 +246,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0174_fileLocked_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0174_fileLocked_xp_win_complete.js
@@ -180,18 +180,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Exclusively lock an existing file so it is in use during the update
   let helperBin = do_get_file(HELPER_BIN_FILE);
   let helperDestDir = getApplyDirFile("a/b/");
@@ -242,8 +242,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0175_fileLocked_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0175_fileLocked_xp_win_partial.js
@@ -181,18 +181,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Not removed for failed update (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : false
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_PARTIAL_FILE);
 
   // Exclusively lock an existing file so it is in use during the update
   let helperBin = do_get_file(HELPER_BIN_FILE);
   let helperDestDir = getApplyDirFile("a/b/");
@@ -243,8 +243,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory doesn't exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0180_fileInUse_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0180_fileInUse_xp_win_complete.js
@@ -186,18 +186,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Launch an existing file so it is in use during the update
   let fileInUseBin = getApplyDirFile(TEST_FILES[14].relPathDir +
                                      TEST_FILES[14].fileName);
   let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", "20"];
@@ -228,8 +228,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_BACKUP_DISCARD);
 
   logTestInfo("testing tobedeleted directory exists");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_true(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0181_fileInUse_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0181_fileInUse_xp_win_partial.js
@@ -189,18 +189,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_IN_USE_WIN_FILE);
 
   // Launch an existing file so it is in use during the update
   let fileInUseBin = getApplyDirFile(TEST_FILES[12].relPathDir +
                                      TEST_FILES[12].fileName);
   let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", "20"];
@@ -231,8 +231,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_BACKUP_DISCARD);
 
   logTestInfo("testing tobedeleted directory exists");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_true(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0182_rmrfdirFileInUse_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0182_rmrfdirFileInUse_xp_win_complete.js
@@ -186,18 +186,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   let fileInUseBin = getApplyDirFile(TEST_DIRS[4].relPathDir +
                                      TEST_DIRS[4].subDirs[0] +
                                      TEST_DIRS[4].subDirFiles[0]);
   // Remove the empty file created for the test so the helper application can
@@ -238,8 +238,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_BACKUP_DISCARD);
 
   logTestInfo("testing tobedeleted directory exists");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_true(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0183_rmrfdirFileInUse_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0183_rmrfdirFileInUse_xp_win_partial.js
@@ -229,18 +229,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   setupUpdaterTest(MAR_IN_USE_WIN_FILE);
 
   let fileInUseBin = getApplyDirFile(TEST_DIRS[2].relPathDir +
                                      TEST_DIRS[2].files[0]);
   // Remove the empty file created for the test so the helper application can
   // replace it.
@@ -279,8 +279,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_BACKUP_DISCARD);
 
   logTestInfo("testing tobedeleted directory exists");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_true(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0184_fileInUse_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0184_fileInUse_xp_win_complete.js
@@ -186,18 +186,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Launch an existing file so it is in use during the update
   let fileInUseBin = getApplyDirFile(TEST_FILES[14].relPathDir +
                                      TEST_FILES[14].fileName);
@@ -242,8 +242,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0185_fileInUse_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0185_fileInUse_xp_win_partial.js
@@ -189,18 +189,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_IN_USE_WIN_FILE);
 
   // Launch an existing file so it is in use during the update
   let fileInUseBin = getApplyDirFile(TEST_FILES[12].relPathDir +
                                      TEST_FILES[12].fileName);
@@ -245,8 +245,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0186_rmrfdirFileInUse_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0186_rmrfdirFileInUse_xp_win_complete.js
@@ -186,18 +186,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   let fileInUseBin = getApplyDirFile(TEST_DIRS[4].relPathDir +
                                      TEST_DIRS[4].subDirs[0] +
                                      TEST_DIRS[4].subDirFiles[0]);
@@ -251,8 +251,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0187_rmrfdirFileInUse_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0187_rmrfdirFileInUse_xp_win_partial.js
@@ -229,18 +229,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_IN_USE_WIN_FILE);
 
   let fileInUseBin = getApplyDirFile(TEST_DIRS[2].relPathDir +
                                      TEST_DIRS[2].files[0]);
   // Remove the empty file created for the test so the helper application can
@@ -292,8 +292,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0188_fileInUse_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0188_fileInUse_xp_win_complete.js
@@ -186,18 +186,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   // Launch an existing file so it is in use during the update
   let fileInUseBin = getApplyDirFile(TEST_FILES[14].relPathDir +
                                      TEST_FILES[14].fileName);
@@ -241,8 +241,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0189_fileInUse_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0189_fileInUse_xp_win_partial.js
@@ -189,18 +189,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_IN_USE_WIN_FILE);
 
   // Launch an existing file so it is in use during the update
   let fileInUseBin = getApplyDirFile(TEST_FILES[12].relPathDir +
                                      TEST_FILES[12].fileName);
@@ -244,8 +244,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0190_rmrfdirFileInUse_xp_win_complete.js
+++ b/toolkit/mozapps/update/test/unit/test_0190_rmrfdirFileInUse_xp_win_complete.js
@@ -186,18 +186,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by precomplete (rmdir)",
   relPathDir   : "a/b/2/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_COMPLETE_FILE);
 
   let fileInUseBin = getApplyDirFile(TEST_DIRS[4].relPathDir +
                                      TEST_DIRS[4].subDirs[0] +
                                      TEST_DIRS[4].subDirFiles[0]);
@@ -250,8 +250,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_0191_rmrfdirFileInUse_xp_win_partial.js
+++ b/toolkit/mozapps/update/test/unit/test_0191_rmrfdirFileInUse_xp_win_partial.js
@@ -229,18 +229,18 @@ ADDITIONAL_TEST_DIRS = [
 }, {
   description  : "Removed by update.manifest (rmdir)",
   relPathDir   : "a/b/1/",
   dirRemoved   : true
 }];
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(cleanupUpdaterTest);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   gBackgroundUpdate = true;
   setupUpdaterTest(MAR_IN_USE_WIN_FILE);
 
   let fileInUseBin = getApplyDirFile(TEST_DIRS[2].relPathDir +
                                      TEST_DIRS[2].files[0]);
   // Remove the empty file created for the test so the helper application can
@@ -291,8 +291,12 @@ function checkUpdate() {
   checkUpdateLogContains(ERR_RENAME_FILE);
 
   logTestInfo("testing tobedeleted directory does not exist");
   let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
   do_check_false(toBeDeletedDir.exists());
 
   checkCallbackAppLog();
 }
+
+function end_test() {
+  cleanupUpdaterTest();
+}
--- a/toolkit/mozapps/update/test/unit/test_bug595059.js
+++ b/toolkit/mozapps/update/test/unit/test_bug595059.js
@@ -6,18 +6,18 @@
  * Bug 595059 - begin download of a complete update after a failure applying a
  * partial update.
  */
 
 const TEST_ID = "bug595059";
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("testing Bug 595059 - calling nsIUpdatePrompt::showUpdateError " +
               "should call getNewPrompter and alert on the object returned " +
               "by getNewPrompter when the update.state = " + STATE_FAILED +
               " and the update.errorCode = " + WRITE_ERROR);
 
   removeUpdateDirsAndFiles();
--- a/toolkit/mozapps/update/test/unit/test_bug794211.js
+++ b/toolkit/mozapps/update/test/unit/test_bug794211.js
@@ -7,18 +7,18 @@
 
 const TEST_ID = "bug794211";
 
 // Needs to be in sync w/ nsUpdateService.js
 const NETWORK_ERROR_OFFLINE = 111;
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   logTestInfo("test when an update check fails because the network is " +
               "offline that we check again when the network comes online. " +
               "(Bug 794211)");
   removeUpdateDirsAndFiles();
   setUpdateURLOverride();
   Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO, false);
--- a/toolkit/mozapps/update/test/unit/test_bug833708.js
+++ b/toolkit/mozapps/update/test/unit/test_bug833708.js
@@ -22,19 +22,19 @@ FakeDirProvider.prototype = {
       }
     }
     return null;
   }
 };
 
 function run_test() {
   do_test_pending();
-  do_register_cleanup(end_test);
   DEBUG_AUS_TEST = true;
 
+  // adjustGeneralPaths registers a cleanup function that calls end_test.
   adjustGeneralPaths();
 
   removeUpdateDirsAndFiles();
   setUpdateURLOverride();
   overrideXHR(xhr_pt1);
   standardInit();
 
   logTestInfo("testing that error codes set from a directory provider propagate" +