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
--- 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) {