2. Move gProcessObserver and gTimerCallback to head_update.js.in - Bug 879612 - Move app update common xpcshell test code into head_update.js.in. r=bbondy
authorRobert Strong <robert.bugzilla@gmail.com>
Wed, 05 Jun 2013 20:25:42 -0700
changeset 145684 a6912e70b705e6528601356881c58d3e5bbc7544
parent 145683 83eb0185fcc3ccb7fa05d2d37c15f7d3336a628c
child 145685 10a6781c41e46473cfb52eca8510750f28adf93a
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs2, 879612
milestone24.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
2. Move gProcessObserver and gTimerCallback to head_update.js.in - 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_0200_app_launch_apply_update.js
toolkit/mozapps/update/test/unit/test_0201_app_launch_apply_update.js
toolkit/mozapps/update/test/unit/test_0203_app_launch_apply_update.js
toolkit/mozapps/update/test_svc/unit/test_0201_app_launch_apply_update_svc.js
toolkit/mozapps/update/test_svc/unit/test_0203_app_launch_apply_update_svc.js
--- a/toolkit/mozapps/update/test/unit/head_update.js.in
+++ b/toolkit/mozapps/update/test/unit/head_update.js.in
@@ -2150,16 +2150,48 @@ function getAppDir() {
     dir.append("MacOS");
   } else if (IS_WIN && gWindowsBinDir) {
     dir = gWindowsBinDir.clone();
   }
   return dir;
 }
 
 /**
+ * The observer for the call to nsIProcess:runAsync.
+ */
+let gProcessObserver = {
+  observe: function PO_observe(subject, topic, data) {
+    logTestInfo("topic " + topic + ", process exitValue " + gProcess.exitValue);
+    if (gAppTimer) {
+      gAppTimer.cancel();
+      gAppTimer = null;
+    }
+    if (topic != "process-finished" || gProcess.exitValue != 0) {
+      do_throw("Failed to launch application");
+    }
+    do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
+  },
+  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIObserver])
+};
+
+/**
+ * The timer callback to kill the process if it takes too long.
+ */
+let gTimerCallback = {
+  notify: function TC_notify(aTimer) {
+    gAppTimer = null;
+    if (gProcess.isRunning) {
+      gProcess.kill();
+    }
+    do_throw("launch application timer expired");
+  },
+  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsITimerCallback])
+};
+
+/**
  * Gets the nsIFile references for the shell script to retrieve the Mac OS X
  * version and the nsIFile to pipe the output of the shell script. If either of
  * these files exist they will be removed by this function.
  *
  * @return  array containing two nsIFile references. The first array member is
  *          the nsIFile for the shell script to launch to get the Mac OS X
  *          version and the second array member is the nsIFile for the piped
  *          output from the shell script.
--- a/toolkit/mozapps/update/test/unit/test_0200_app_launch_apply_update.js
+++ b/toolkit/mozapps/update/test/unit/test_0200_app_launch_apply_update.js
@@ -189,48 +189,16 @@ function end_test() {
       getVersionScriptAndFile();
     }
   }
 
   cleanUp();
 }
 
 /**
- * The observer for the call to nsIProcess:runAsync.
- */
-let gProcessObserver = {
-  observe: function PO_observe(subject, topic, data) {
-    logTestInfo("topic " + topic + ", process exitValue " + gProcess.exitValue);
-    if (gAppTimer) {
-      gAppTimer.cancel();
-      gAppTimer = null;
-    }
-    if (topic != "process-finished" || gProcess.exitValue != 0) {
-      do_throw("Failed to launch application");
-    }
-    do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIObserver])
-};
-
-/**
- * The timer callback to kill the process if it takes too long.
- */
-let gTimerCallback = {
-  notify: function TC_notify(aTimer) {
-    gAppTimer = null;
-    if (gProcess.isRunning) {
-      gProcess.kill();
-    }
-    do_throw("launch application timer expired");
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsITimerCallback])
-};
-
-/**
  * Gets the directory where the update adds / removes the files contained in the
  * update.
  *
  * @return  nsIFile for the directory where the update adds / removes the files
  *          contained in the update mar.
  */
 function getUpdateTestDir() {
   let updateTestDir = getCurrentProcessDir();
--- a/toolkit/mozapps/update/test/unit/test_0201_app_launch_apply_update.js
+++ b/toolkit/mozapps/update/test/unit/test_0201_app_launch_apply_update.js
@@ -248,48 +248,16 @@ function end_test() {
       // This will delete the version script and version file if they exist.
       getVersionScriptAndFile();
     }
   }
 
   cleanUp();
 }
 
-/**
- * The observer for the call to nsIProcess:runAsync.
- */
-let gProcessObserver = {
-  observe: function PO_observe(subject, topic, data) {
-    logTestInfo("topic " + topic + ", process exitValue " + gProcess.exitValue);
-    if (gAppTimer) {
-      gAppTimer.cancel();
-      gAppTimer = null;
-    }
-    if (topic != "process-finished" || gProcess.exitValue != 0) {
-      do_throw("Failed to launch application");
-    }
-    do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIObserver])
-};
-
-/**
- * The timer callback to kill the process if it takes too long.
- */
-let gTimerCallback = {
-  notify: function TC_notify(aTimer) {
-    gAppTimer = null;
-    if (gProcess.isRunning) {
-      gProcess.kill();
-    }
-    do_throw("launch application timer expired");
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsITimerCallback])
-};
-
 function shouldAdjustPathsOnMac() {
   // When running xpcshell tests locally, xpcshell and firefox-bin do not live
   // in the same directory.
   let dir = getCurrentProcessDir();
   return (IS_MACOSX && dir.leafName != "MacOS");
 }
 
 /**
--- a/toolkit/mozapps/update/test/unit/test_0203_app_launch_apply_update.js
+++ b/toolkit/mozapps/update/test/unit/test_0203_app_launch_apply_update.js
@@ -277,48 +277,16 @@ function end_test() {
       // This will delete the version script and version file if they exist.
       getVersionScriptAndFile();
     }
   }
 
   cleanUp();
 }
 
-/**
- * The observer for the call to nsIProcess:runAsync.
- */
-let gProcessObserver = {
-  observe: function PO_observe(subject, topic, data) {
-    logTestInfo("topic " + topic + ", process exitValue " + gProcess.exitValue);
-    if (gAppTimer) {
-      gAppTimer.cancel();
-      gAppTimer = null;
-    }
-    if (topic != "process-finished" || gProcess.exitValue != 0) {
-      do_throw("Failed to launch application");
-    }
-    do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIObserver])
-};
-
-/**
- * The timer callback to kill the process if it takes too long.
- */
-let gTimerCallback = {
-  notify: function TC_notify(aTimer) {
-    gAppTimer = null;
-    if (gProcess.isRunning) {
-      gProcess.kill();
-    }
-    do_throw("launch application timer expired");
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsITimerCallback])
-};
-
 function shouldAdjustPathsOnMac() {
   // When running xpcshell tests locally, xpcshell and firefox-bin do not live
   // in the same directory.
   let dir = getCurrentProcessDir();
   return (IS_MACOSX && dir.leafName != "MacOS");
 }
 
 /**
--- a/toolkit/mozapps/update/test_svc/unit/test_0201_app_launch_apply_update_svc.js
+++ b/toolkit/mozapps/update/test_svc/unit/test_0201_app_launch_apply_update_svc.js
@@ -254,48 +254,16 @@ function end_test() {
       // This will delete the version script and version file if they exist.
       getVersionScriptAndFile();
     }
   }
 
   cleanUp();
 }
 
-/**
- * The observer for the call to nsIProcess:runAsync.
- */
-let gProcessObserver = {
-  observe: function PO_observe(subject, topic, data) {
-    logTestInfo("topic " + topic + ", process exitValue " + gProcess.exitValue);
-    if (gAppTimer) {
-      gAppTimer.cancel();
-      gAppTimer = null;
-    }
-    if (topic != "process-finished" || gProcess.exitValue != 0) {
-      do_throw("Failed to launch application");
-    }
-    do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIObserver])
-};
-
-/**
- * The timer callback to kill the process if it takes too long.
- */
-let gTimerCallback = {
-  notify: function TC_notify(aTimer) {
-    gAppTimer = null;
-    if (gProcess.isRunning) {
-      gProcess.kill();
-    }
-    do_throw("launch application timer expired");
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsITimerCallback])
-};
-
 function shouldAdjustPathsOnMac() {
   // When running xpcshell tests locally, xpcshell and firefox-bin do not live
   // in the same directory.
   let dir = getCurrentProcessDir();
   return (IS_MACOSX && dir.leafName != "MacOS");
 }
 
 /**
--- a/toolkit/mozapps/update/test_svc/unit/test_0203_app_launch_apply_update_svc.js
+++ b/toolkit/mozapps/update/test_svc/unit/test_0203_app_launch_apply_update_svc.js
@@ -280,48 +280,16 @@ function end_test() {
       // This will delete the version script and version file if they exist.
       getVersionScriptAndFile();
     }
   }
 
   cleanUp();
 }
 
-/**
- * The observer for the call to nsIProcess:runAsync.
- */
-let gProcessObserver = {
-  observe: function PO_observe(subject, topic, data) {
-    logTestInfo("topic " + topic + ", process exitValue " + gProcess.exitValue);
-    if (gAppTimer) {
-      gAppTimer.cancel();
-      gAppTimer = null;
-    }
-    if (topic != "process-finished" || gProcess.exitValue != 0) {
-      do_throw("Failed to launch application");
-    }
-    do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIObserver])
-};
-
-/**
- * The timer callback to kill the process if it takes too long.
- */
-let gTimerCallback = {
-  notify: function TC_notify(aTimer) {
-    gAppTimer = null;
-    if (gProcess.isRunning) {
-      gProcess.kill();
-    }
-    do_throw("launch application timer expired");
-  },
-  QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsITimerCallback])
-};
-
 function shouldAdjustPathsOnMac() {
   // When running xpcshell tests locally, xpcshell and firefox-bin do not live
   // in the same directory.
   let dir = getCurrentProcessDir();
   return (IS_MACOSX && dir.leafName != "MacOS");
 }
 
 /**