Bug 1348396 - Only show a badge on PanelUI while in fullscreen draft
authorDoug Thayer <dothayer@mozilla.com>
Mon, 10 Apr 2017 11:11:45 -0700
changeset 561557 797a759b194f7f1cca7b144099826951d75f5794
parent 560546 abf145ebd05fe105efbc78b761858c34f7690154
child 624017 48155b5de7e4cb0433d4baab66b2004a85401724
push id53778
push userbmo:dothayer@mozilla.com
push dateWed, 12 Apr 2017 21:25:13 +0000
bugs1348396
milestone55.0a1
Bug 1348396 - Only show a badge on PanelUI while in fullscreen Previously we were showing a doorhanger when the user moused to the top of the screen while in fullscreen mode. However, the doorhanger would disappear before the user had a chance to interact with it. We decided it's best anyway to simply display a badge when the user is in fullscreen, and to reshow the doorhanger when the user exits fullscreen. MozReview-Commit-ID: ENRtXC4wqvZ
browser/components/customizableui/content/panelUI.js
browser/components/customizableui/test/browser_panelUINotifications.js
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -677,18 +677,24 @@ const PanelUI = {
       // since we don't want their doorhangers competing for attention
       doorhangers.forEach(n => { n.dismissed = true; })
       this._hidePopup();
       this._clearBadge();
       if (!this.notifications[0].options.badgeOnly) {
         this._showMenuItem(this.notifications[0]);
       }
     } else if (doorhangers.length > 0) {
-      this._clearBadge();
-      this._showNotificationPanel(doorhangers[0]);
+      if (window.fullScreen) {
+        this._hidePopup();
+        this._showBadge(doorhangers[0]);
+        this._showMenuItem(doorhangers[0]);
+      } else {
+        this._clearBadge();
+        this._showNotificationPanel(doorhangers[0]);
+      }
     } else {
       this._hidePopup();
       this._showBadge(this.notifications[0]);
       this._showMenuItem(this.notifications[0]);
     }
   },
 
   _showNotificationPanel(notification) {
--- a/browser/components/customizableui/test/browser_panelUINotifications.js
+++ b/browser/components/customizableui/test/browser_panelUINotifications.js
@@ -298,8 +298,47 @@ add_task(function* testMultipleNonBadges
     isnot(PanelUI.menuButton.getAttribute("badge-status"), "update-manual", "update-manual badge is hidden on PanelUI button.");
     menuItem = doc.getElementById("PanelUI-update-manual-menu-item");
     is(menuItem.hidden, false, "update-manual menu item is showing.");
 
     menuItem.click();
     ok(updateManualAction.called, "update-manual main action callback was called");
   });
 });
+
+add_task(function* testFullscreen() {
+  let doc = document;
+
+  is(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is closed.");
+  let mainActionCalled = false;
+  let mainAction = {
+    callback: () => { mainActionCalled = true; }
+  };
+  PanelUI.showNotification("update-manual", mainAction);
+
+  isnot(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is showing.");
+  let notifications = [...PanelUI.notificationPanel.children].filter(n => !n.hidden);
+  is(notifications.length, 1, "PanelUI doorhanger is only displaying one notification.");
+  let doorhanger = notifications[0];
+  is(doorhanger.id, "PanelUI-update-manual-notification", "PanelUI is displaying the update-manual notification.");
+
+  let popuphiddenPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popuphidden");
+  EventUtils.synthesizeKey("VK_F11", {});
+  yield popuphiddenPromise;
+  yield new Promise(executeSoon);
+  is(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is closed.");
+
+  window.FullScreen.showNavToolbox();
+  is(PanelUI.menuButton.getAttribute("badge-status"), "update-manual", "Badge is displaying on PanelUI button.");
+
+  let popupshownPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown");
+  EventUtils.synthesizeKey("VK_F11", {});
+  yield popupshownPromise;
+  yield new Promise(executeSoon);
+  isnot(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is showing.");
+  isnot(PanelUI.menuButton.getAttribute("badge-status"), "update-manual", "Badge is not displaying on PanelUI button.");
+
+  let mainActionButton = doc.getAnonymousElementByAttribute(doorhanger, "anonid", "button");
+  mainActionButton.click();
+  ok(mainActionCalled, "Main action callback was called");
+  is(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is closed.");
+  is(PanelUI.menuButton.hasAttribute("badge-status"), false, "Should not have a badge status");
+});