Bug 311614: Update tests. r=rstrong
authorStephen A Pohl <spohl.mozilla.bugs@gmail.com>
Mon, 16 May 2016 16:04:46 -0400
changeset 491541 cde4e42296982c4e676f338bd02465df50aa2b3e
parent 491540 630696ec8c887434d3b798322564d9dfeb2e487f
child 491542 66947a0678313afb4f651eb556f6e64d9442d871
push id47343
push userbmo:dothayer@mozilla.com
push dateWed, 01 Mar 2017 22:58:58 +0000
reviewersrstrong
bugs311614
milestone49.0a1
Bug 311614: Update tests. r=rstrong
toolkit/mozapps/update/nsUpdateService.js
toolkit/mozapps/update/tests/chrome/test_0071_notify_verifyFailPartial_noComplete.xul
toolkit/mozapps/update/tests/chrome/test_0072_notify_verifyFailComplete_noPartial.xul
toolkit/mozapps/update/tests/chrome/test_0073_notify_verifyFailPartialComplete.xul
toolkit/mozapps/update/tests/chrome/test_0074_notify_verifyFailPartial_successComplete.xul
toolkit/mozapps/update/tests/chrome/test_0081_error_patchApplyFailure_partial_only.xul
toolkit/mozapps/update/tests/chrome/test_0082_error_patchApplyFailure_complete_only.xul
toolkit/mozapps/update/tests/chrome/test_0083_error_patchApplyFailure_partial_complete.xul
toolkit/mozapps/update/tests/chrome/test_0084_error_patchApplyFailure_verify_failed.xul
toolkit/mozapps/update/tests/chrome/test_0091_installed.xul
toolkit/mozapps/update/tests/data/shared.js
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -1991,16 +1991,18 @@ UpdateService.prototype = {
         // intentional fallthrough
       case "sessionstore-windows-restored":
       case "mail-startup-done":
       case "xul-window-visible":
         if (Services.appinfo.ID in APPID_TO_TOPIC) {
           Services.obs.removeObserver(this,
                                       APPID_TO_TOPIC[Services.appinfo.ID]);
         }
+        // intentional fallthrough
+      case "mochitest-app-startup-finished":
         // Clean up any extant updates
         this._postUpdateProcessing();
         break;
       case "network:offline-status-changed":
         this._offlineStatusChanged(data);
         break;
       case "nsPref:changed":
         if (data == PREF_APP_UPDATE_LOG) {
--- a/toolkit/mozapps/update/tests/chrome/test_0071_notify_verifyFailPartial_noComplete.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0071_notify_verifyFailPartial_noComplete.xul
@@ -34,17 +34,17 @@ function runTest() {
                                      Services.appinfo.platformVersion);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_DOWNLOADING);
   reloadUpdateManagerData();
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/chrome/test_0072_notify_verifyFailComplete_noPartial.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0072_notify_verifyFailComplete_noPartial.xul
@@ -34,17 +34,17 @@ function runTest() {
                                      Services.appinfo.platformVersion);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_DOWNLOADING);
   reloadUpdateManagerData();
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/chrome/test_0073_notify_verifyFailPartialComplete.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0073_notify_verifyFailPartialComplete.xul
@@ -37,17 +37,17 @@ function runTest() {
                                      null, null, null, null, null, "false");
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_DOWNLOADING);
   reloadUpdateManagerData();
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/chrome/test_0074_notify_verifyFailPartial_successComplete.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0074_notify_verifyFailPartial_successComplete.xul
@@ -37,17 +37,17 @@ function runTest() {
                                      null, null, null, null, null, "false");
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_DOWNLOADING);
   reloadUpdateManagerData();
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/chrome/test_0081_error_patchApplyFailure_partial_only.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0081_error_patchApplyFailure_partial_only.xul
@@ -35,17 +35,17 @@ function runTest() {
                                      null, null, null, null, null, "false");
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_FAILED + ": " + CRC_ERROR);
   reloadUpdateManagerData();
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/chrome/test_0082_error_patchApplyFailure_complete_only.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0082_error_patchApplyFailure_complete_only.xul
@@ -34,17 +34,17 @@ function runTest() {
                                      Services.appinfo.platformVersion);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_FAILED + ": " + CRC_ERROR);
   reloadUpdateManagerData();
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/chrome/test_0083_error_patchApplyFailure_partial_complete.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0083_error_patchApplyFailure_partial_complete.xul
@@ -49,17 +49,17 @@ function runTest() {
                                      null, null, null, null, null, "false");
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_FAILED + ": " + CRC_ERROR);
   reloadUpdateManagerData();
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/chrome/test_0084_error_patchApplyFailure_verify_failed.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0084_error_patchApplyFailure_verify_failed.xul
@@ -50,17 +50,17 @@ function runTest() {
                                      null, null, null, null, null, "false");
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
 
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_FAILED + ": " + CRC_ERROR);
   reloadUpdateManagerData();
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/chrome/test_0091_installed.xul
+++ b/toolkit/mozapps/update/tests/chrome/test_0091_installed.xul
@@ -32,17 +32,17 @@ function runTest() {
                                     STATE_PENDING);
   let updates = getLocalUpdateString(patches, null, null, null,
                                      Services.appinfo.version,
                                      Services.appinfo.platformVersion);
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
   writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
   writeStatusFile(STATE_SUCCEEDED);
 
-  initUpdateServiceStub();
+  signalAppStartupFinished();
 }
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <p id="display"></p>
   <div id="content" style="display: none"></div>
--- a/toolkit/mozapps/update/tests/data/shared.js
+++ b/toolkit/mozapps/update/tests/data/shared.js
@@ -132,16 +132,23 @@ XPCOMUtils.defineLazyServiceGetter(this,
                                    "@mozilla.org/process/environment;1",
                                    "nsIEnvironment");
 
 XPCOMUtils.defineLazyGetter(this, "gZipW", function test_gZipW() {
   return Cc["@mozilla.org/zipwriter;1"].
          createInstance(Ci.nsIZipWriter);
 });
 
+function signalAppStartupFinished() {
+  let aus = Cc["@mozilla.org/updates/update-service;1"].
+            getService(Ci.nsIApplicationUpdateService).
+            QueryInterface(Ci.nsIObserver);
+  aus.observe(null, "mochitest-app-startup-finished", "");
+}
+
 /* Initializes the update service stub */
 function initUpdateServiceStub() {
   Cc["@mozilla.org/updates/update-service-stub;1"].
   createInstance(Ci.nsISupports);
 }
 
 /* Reloads the update metadata from disk */
 function reloadUpdateManagerData() {