Bug 607708 - A second download of an update is cached so we should simply check for the finished wizard page. r=gmealer mozilla1.9.1
authorHenrik Skupin <hskupin@mozilla.com>
Wed, 27 Oct 2010 21:08:10 +0200
branchmozilla1.9.1
changeset 795 18134d50cc941fc817eee0092585305265e81d92
parent 793 399e015f0ffc28d1bb056f4445373bc4e90e8218
child 803 26a82a30f5690ec5323a2c7d5524d66b05e544b4
push id698
push userhskupin@mozilla.com
push dateWed, 27 Oct 2010 20:08:54 +0000
reviewersgmealer
bugs607708
Bug 607708 - A second download of an update is cached so we should simply check for the finished wizard page. r=gmealer
shared-modules/testSoftwareUpdateAPI.js
--- a/shared-modules/testSoftwareUpdateAPI.js
+++ b/shared-modules/testSoftwareUpdateAPI.js
@@ -183,19 +183,24 @@ softwareUpdate.prototype = {
                                 {currentChannel: channel, expectedChannel: prefChannel});
     }
 
     // Click the next button
     var next = new elementslib.Lookup(this._controller.window.document,
                                       this._buttons.next);
     this._controller.click(next);
 
-    // Wait until update has been downloaded
-    var progress = this._controller.window.document.getElementById("downloadProgress");
-    this._controller.waitForEval("subject.value == 100", timeout, 100, progress);
+    // Wait for the download page - if it fails the update was already cached
+    try {
+      this.waitForWizardStep("downloading");
+
+      this.waitforDownloadFinished(timeout);
+    } catch (ex) {
+      this.waitForWizardStep("finished");
+    }
   },
 
   /**
    * Update the update.status file and set the status to 'failed:6'
    */
   forceFallback : function softwareUpdate_forceFallback() {
     var dirService = Cc["@mozilla.org/file/directory_service;1"]
                         .getService(Ci.nsIProperties);
@@ -278,10 +283,34 @@ softwareUpdate.prototype = {
   waitForDialogOpen : function softwareUpdate_waitForDialogOpen(browserController) {
     this._controller = this._UtilsAPI.handleWindow("type", "Update:Wizard",
                                                    null, true);
     this._wizard = this._controller.window.document.getElementById('updates');
 
     // Wait until the dummy wizard page isn't visible anymore
     this._controller.waitForEval("subject.currentStep != 'dummy'", gTimeout, 100, this);
     this._controller.window.focus();
+  },
+
+  /**
+   * Wait until the download has been finished
+   *
+   * @param {number} timeout
+   *        Timeout the download has to stop
+   */
+  waitforDownloadFinished: function softwareUpdate_waitForDownloadFinished(timeout) {
+    timeout = timeout ? timeout : gTimeoutUpdateDownload;
+
+    // Wait until update has been downloaded
+    var progress = this._controller.window.document.getElementById("downloadProgress");
+    this._controller.waitForEval("subject.value == 100", timeout, 100, progress);
+
+    this.waitForWizardStep("finished");
+  },
+
+  /**
+   * Waits for the given step of the update dialog wizard
+   */
+  waitForWizardStep : function softwareUpdate_waitForWizardStep(step) {
+    this._controller.waitForEval("subject.currentStep == '" + step + "'",
+                                 gTimeout, 100, this);
   }
 }