Backout 391241169bec (bug 1171852) for unit test failures
authorMark Banner <standard8@mozilla.com>
Sat, 20 Jun 2015 20:21:26 +0100
changeset 249839 e67d1044c4395975225f6adc7d4f1714233dcb2f
parent 249838 1f7db5d87e8059e7e2947c4e1ece06e610107faf
child 249840 ac02ae385e7521cd4e53d51dba815694ae2a58ce
push id28939
push usercbook@mozilla.com
push dateMon, 22 Jun 2015 11:56:54 +0000
treeherdermozilla-central@cddf3b36b5e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1171852
milestone41.0a1
backs out391241169becf6ed866341b96c7a88d4325ed83b
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
Backout 391241169bec (bug 1171852) for unit test failures
browser/base/content/browser.js
toolkit/mozapps/update/nsUpdateService.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2566,26 +2566,24 @@ let gMenuButtonUpdateBadge = {
     if (this.enabled) {
       try {
         this.badgeWaitTime = Services.prefs.getIntPref("app.update.badgeWaitTime");
       } catch (e) {
         this.badgeWaitTime = 345600; // 4 days
       }
       PanelUI.menuButton.classList.add("badged-button");
       Services.obs.addObserver(this, "update-staged", false);
-      Services.obs.addObserver(this, "update-downloaded", false);
     }
   },
 
   uninit: function () {
     if (this.timer)
       this.timer.cancel();
     if (this.enabled) {
       Services.obs.removeObserver(this, "update-staged");
-      Services.obs.removeObserver(this, "update-downloaded");
       PanelUI.panel.removeEventListener("popupshowing", this, true);
       this.enabled = false;
     }
   },
 
   onMenuPanelCommand: function(event) {
     if (event.originalTarget.getAttribute("update-status") === "succeeded") {
       // restart the app
@@ -2599,65 +2597,82 @@ let gMenuButtonUpdateBadge = {
     } else {
       // open the page for manual update
       let url = Services.urlFormatter.formatURLPref("app.update.url.manual");
       openUILinkIn(url, "tab");
     }
   },
 
   observe: function (subject, topic, status) {
-    if (status == "failed") {
-      // Background update has failed, let's show the UI responsible for
-      // prompting the user to update manually.
-      this.displayBadge(false);
-      this.uninit();
-      return;
-    }
-
-    // Give the user badgeWaitTime seconds to react before prompting.
-    this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-    this.timer.initWithCallback(this, this.badgeWaitTime * 1000,
-                                this.timer.TYPE_ONE_SHOT);
-    // The timer callback will call uninit() when it completes.
+    const STATE_DOWNLOADING     = "downloading";
+    const STATE_PENDING         = "pending";
+    const STATE_PENDING_SVC     = "pending-service";
+    const STATE_APPLIED         = "applied";
+    const STATE_APPLIED_SVC     = "applied-service";
+    const STATE_FAILED          = "failed";
+
+    let updateButton = document.getElementById("PanelUI-update-status");
+
+    let updateButtonText;
+    let stringId;
+
+    // Update the UI when the background updater is finished.
+    switch (status) {
+      case STATE_APPLIED:
+      case STATE_APPLIED_SVC:
+      case STATE_PENDING:
+      case STATE_PENDING_SVC:
+        if (this.timer) {
+          return;
+        }
+        // Give the user badgeWaitTime seconds to react before prompting.
+        this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+        this.timer.initWithCallback(this, this.badgeWaitTime * 1000,
+                                    this.timer.TYPE_ONE_SHOT);
+        // The timer callback will call uninit() when it completes.
+        break;
+      case STATE_FAILED:
+        // Background update has failed, let's show the UI responsible for
+        // prompting the user to update manually.
+        PanelUI.menuButton.setAttribute("update-status", "failed");
+        PanelUI.menuButton.setAttribute("badge", "!");
+
+        stringId = "appmenu.updateFailed.description";
+        updateButtonText = gNavigatorBundle.getString(stringId);
+
+        updateButton.setAttribute("label", updateButtonText);
+        updateButton.setAttribute("update-status", "failed");
+        updateButton.hidden = false;
+
+        PanelUI.panel.addEventListener("popupshowing", this, true);
+
+        this.uninit();
+        break;
+    }
   },
 
   notify: function () {
     // If the update is successfully applied, or if the updater has fallen back
     // to non-staged updates, add a badge to the hamburger menu to indicate an
     // update will be applied once the browser restarts.
-    this.displayBadge(true);
-    this.uninit();
-  },
-
-  displayBadge: function (succeeded) {
-    let status = succeeded ? "succeeded" : "failed";
-    PanelUI.menuButton.setAttribute("update-status", status);
-    if (!succeeded) {
-      PanelUI.menuButton.setAttribute("badge", "!");
-    }
-
-    let stringId;
-    let updateButtonText;
-    if (succeeded) {
-      let brandBundle = document.getElementById("bundle_brand");
-      let brandShortName = brandBundle.getString("brandShortName");
-      stringId = "appmenu.restartNeeded.description";
-      updateButtonText = gNavigatorBundle.getFormattedString(stringId,
-                                                             [brandShortName]);
-    } else {
-      stringId = "appmenu.updateFailed.description";
-      updateButtonText = gNavigatorBundle.getString(stringId);
-    }
+    PanelUI.menuButton.setAttribute("update-status", "succeeded");
+
+    let brandBundle = document.getElementById("bundle_brand");
+    let brandShortName = brandBundle.getString("brandShortName");
+    stringId = "appmenu.restartNeeded.description";
+    updateButtonText = gNavigatorBundle.getFormattedString(stringId,
+                                                           [brandShortName]);
 
     let updateButton = document.getElementById("PanelUI-update-status");
     updateButton.setAttribute("label", updateButtonText);
-    updateButton.setAttribute("update-status", status);
+    updateButton.setAttribute("update-status", "succeeded");
     updateButton.hidden = false;
 
     PanelUI.panel.addEventListener("popupshowing", this, true);
+    this.uninit();
   },
 
   handleEvent: function(e) {
     if (e.type === "popupshowing") {
       PanelUI.menuButton.removeAttribute("badge");
       PanelUI.panel.removeEventListener("popupshowing", this, true);
     }
   }
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -4563,26 +4563,23 @@ UpdatePrompt.prototype = {
                            UPDATE_WINDOW_NAME, "updatesavailable", update,
                            title, text, imageUrl);
   },
 
   /**
    * See nsIUpdateService.idl
    */
   showUpdateDownloaded: function UP_showUpdateDownloaded(update, background) {
-    if (background && getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false))
-      return;
-    }
-    // Trigger the display of the hamburger menu badge.
-    Services.obs.notifyObservers(null, "update-downloaded", update.state);
-
     if (this._getAltUpdateWindow())
       return;
 
     if (background) {
+      if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false))
+        return;
+
       var stringsPrefix = "updateDownloaded_" + update.type + ".";
       var title = gUpdateBundle.formatStringFromName(stringsPrefix + "title",
                                                      [update.name], 1);
       var text = gUpdateBundle.GetStringFromName(stringsPrefix + "text");
       var imageUrl = "";
       this._showUnobtrusiveUI(null, URI_UPDATE_PROMPT_DIALOG, null,
                               UPDATE_WINDOW_NAME, "finishedBackground", update,
                               title, text, imageUrl);