Bug 1399478 - Fix buttonhighlight for doorhangers without a mainaction. r=steveck draft
authorJohann Hofmann <jhofmann@mozilla.com>
Sat, 16 Sep 2017 15:30:50 +0200
changeset 666229 7ff7f85ed7cd538a1b499bf51e4cb11594a83a42
parent 666127 ae39864562c6048fdc2950c5dfedb48e247c3300
child 732025 f36050752e6086bd4aae84caaa561accc0af2096
push id80325
push userbmo:jhofmann@mozilla.com
push dateMon, 18 Sep 2017 08:56:58 +0000
reviewerssteveck
bugs1399478
milestone57.0a1
Bug 1399478 - Fix buttonhighlight for doorhangers without a mainaction. r=steveck We allow doorhangers to optionally disable the blue button highlight for their main actions, but didn't account for the fact that we display a default "OK" button when no mainAction was provided. MozReview-Commit-ID: 6ndWju3ytyq
browser/base/content/test/popupNotifications/browser_popupNotification.js
toolkit/modules/PopupNotifications.jsm
--- a/browser/base/content/test/popupNotifications/browser_popupNotification.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification.js
@@ -208,16 +208,18 @@ var tests = [
   { id: "Test#9",
     run() {
       this.notifyObj = new BasicNotification(this.id);
       this.notifyObj.mainAction = null;
       this.notifyObj.secondaryActions = null;
       this.notification = showNotification(this.notifyObj);
     },
     onShown(popup) {
+      let notification = popup.childNodes[0];
+      is(notification.getAttribute("buttonhighlight"), "true", "default action is highlighted");
       triggerMainCommand(popup);
     },
     onHidden(popup) {
       ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked");
       ok(!this.notifyObj.dismissalCallbackTriggered, "dismissal callback wasn't triggered");
       ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
     }
   },
@@ -228,16 +230,17 @@ var tests = [
     run() {
       this.notifyObj = new BasicNotification(this.id);
       this.notifyObj.mainAction = null;
       this.notification = showNotification(this.notifyObj);
     },
     onShown(popup) {
       let notification = popup.childNodes[0];
       is(notification.getAttribute("secondarybuttonhidden"), "true", "secondary button is hidden");
+      is(notification.getAttribute("buttonhighlight"), "true", "default action is highlighted");
       triggerMainCommand(popup);
     },
     onHidden(popup) {
       ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked");
       ok(!this.notifyObj.dismissalCallbackTriggered, "dismissal callback wasn't triggered");
       ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
     }
   },
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -782,16 +782,17 @@ PopupNotifications.prototype = {
         popupnotification.setAttribute("buttonhighlight", !n.mainAction.disableHighlight);
         popupnotification.setAttribute("buttoncommand", "PopupNotifications._onButtonEvent(event, 'buttoncommand');");
         popupnotification.setAttribute("dropmarkerpopupshown", "PopupNotifications._onButtonEvent(event, 'dropmarkerpopupshown');");
         popupnotification.setAttribute("learnmoreclick", "PopupNotifications._onButtonEvent(event, 'learnmoreclick');");
         popupnotification.setAttribute("menucommand", "PopupNotifications._onMenuCommand(event);");
       } else {
         // Enable the default button to let the user close the popup if the close button is hidden
         popupnotification.setAttribute("buttoncommand", "PopupNotifications._onButtonEvent(event, 'buttoncommand');");
+        popupnotification.setAttribute("buttonhighlight", "true");
         popupnotification.removeAttribute("buttonlabel");
         popupnotification.removeAttribute("buttonaccesskey");
         popupnotification.removeAttribute("dropmarkerpopupshown");
         popupnotification.removeAttribute("learnmoreclick");
         popupnotification.removeAttribute("menucommand");
       }
 
       if (n.options.popupIconClass) {