Bug 1186521 - Enforce new requirements for Hamburger menu badges. r=markh
authorEdouard Oger <edouard.oger@gmail.com>
Thu, 06 Aug 2015 14:47:32 +1000
changeset 256581 4df929a2069c682561080347b51a4f177ff8c29f
parent 256580 8d243e99ae6e68a1d40f463f04eac4c309c4a128
child 256582 f97d6003cdbecbe9588b7492f86e3d5100b21350
push id29180
push userkwierso@gmail.com
push dateFri, 07 Aug 2015 00:23:32 +0000
treeherdermozilla-central@b735f4eea935 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1186521
milestone42.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 1186521 - Enforce new requirements for Hamburger menu badges. r=markh
browser/base/content/browser.js
browser/base/content/test/general/browser_menuButtonBadgeManager.js
browser/themes/shared/customizableui/panelUIOverlay.inc.css
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1386,16 +1386,18 @@ var gBrowserInit = {
 
     LoopUI.init();
 
     gBrowserThumbnails.init();
 
     // Add Devtools menuitems and listeners
     gDevToolsBrowser.registerBrowserWindow(window);
 
+    gMenuButtonBadgeManager.init();
+
     gMenuButtonUpdateBadge.init();
 
     window.addEventListener("mousemove", MousePosTracker, false);
     window.addEventListener("dragover", MousePosTracker, false);
 
     gNavToolbox.addEventListener("customizationstarting", CustomizationHandler);
     gNavToolbox.addEventListener("customizationchange", CustomizationHandler);
     gNavToolbox.addEventListener("customizationending", CustomizationHandler);
@@ -1541,16 +1543,18 @@ var gBrowserInit = {
     BrowserOnClick.uninit();
 
     DevEdition.uninit();
 
     TrackingProtection.uninit();
 
     gMenuButtonUpdateBadge.uninit();
 
+    gMenuButtonBadgeManager.uninit();
+
     SidebarUI.uninit();
 
     // Now either cancel delayedStartup, or clean up the services initialized from
     // it.
     if (this._boundDelayedStartup) {
       this._cancelDelayedStartup();
     } else {
       if (Win7Features)
@@ -2571,16 +2575,30 @@ function PageProxyClickHandler(aEvent)
 
 let gMenuButtonBadgeManager = {
   BADGEID_APPUPDATE: "update",
   BADGEID_FXA: "fxa",
 
   fxaBadge: null,
   appUpdateBadge: null,
 
+  init: function () {
+    PanelUI.panel.addEventListener("popupshowing", this, true);
+  },
+
+  uninit: function () {
+    PanelUI.panel.removeEventListener("popupshowing", this, true);
+  },
+
+  handleEvent: function (e) {
+    if (e.type === "popupshowing") {
+      this.clearBadges();
+    }
+  },
+
   _showBadge: function () {
     let badgeToShow = this.appUpdateBadge || this.fxaBadge;
 
     if (badgeToShow) {
       PanelUI.menuButton.setAttribute("badge-status", badgeToShow);
     } else {
       PanelUI.menuButton.removeAttribute("badge-status");
     }
@@ -2602,16 +2620,22 @@ let gMenuButtonBadgeManager = {
       Cu.reportError("badgeStatus must be defined");
       return;
     }
     this._changeBadge(badgeId, badgeStatus);
   },
 
   removeBadge: function (badgeId) {
     this._changeBadge(badgeId);
+  },
+
+  clearBadges: function () {
+    this.appUpdateBadge = null;
+    this.fxaBadge = null;
+    this._showBadge();
   }
 };
 
 // Setup the hamburger button badges for updates, if enabled.
 let gMenuButtonUpdateBadge = {
   enabled: false,
   badgeWaitTime: 0,
   timer: null,
--- a/browser/base/content/test/general/browser_menuButtonBadgeManager.js
+++ b/browser/base/content/test/general/browser_menuButtonBadgeManager.js
@@ -20,9 +20,18 @@ add_task(function* testButtonActivities(
   gMenuButtonBadgeManager.addBadge("unknownbadge", "attr");
   is(menuButton.getAttribute("badge-status"), "update-failed", "Should not have changed badge status");
 
   gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE);
   is(menuButton.getAttribute("badge-status"), "fxa-needs-authentication", "Should have fxa-needs-authentication badge status");
 
   gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_FXA);
   is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status");
+
+  yield PanelUI.show();
+  is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status (Hamburger menu opened)");
+  PanelUI.hide();
+
+  gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_FXA, "fxa-needs-authentication");
+  gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_UPDATE, "update-succeeded");
+  gMenuButtonBadgeManager.clearBadges();
+  is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status (clearBadges called)");
 });
--- a/browser/themes/shared/customizableui/panelUIOverlay.inc.css
+++ b/browser/themes/shared/customizableui/panelUIOverlay.inc.css
@@ -528,16 +528,37 @@ toolbarpaletteitem[place="palette"] > to
   width: 47px;
   padding-top: 1px;
   display: block;
   text-align: center;
   position: relative;
   top: 25%;
 }
 
+#PanelUI-update-status[update-status]::after {
+  content: "";
+  width: 14px;
+  height: 14px;
+  margin-right: 16.5px;
+  box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.2) inset, 0px -1px 0px rgba(0, 0, 0, 0.1) inset, 0px 1px 0px rgba(12, 27, 38, 0.2);
+  border-radius: 2px;
+  background-size: contain;
+  display: -moz-box;
+}
+
+#PanelUI-update-status[update-status="succeeded"]::after {
+  background-image: url(chrome://browser/skin/update-badge.svg);
+  background-color: #74BF43;
+}
+
+#PanelUI-update-status[update-status="failed"]::after {
+  background-image: url(chrome://browser/skin/update-badge-failed.svg);
+  background-color: #D90000;
+}
+
 #PanelUI-fxa-status {
   display: flex;
   flex: 1 1 0%;
   width: 1px;
 }
 
 #PanelUI-footer-inner,
 #PanelUI-footer-fxa:not([hidden]) {