зеркало из https://github.com/mozilla/gecko-dev.git
Bug 854740: PopupNotifications doesn't handle showing a dismissed notification after showing a normal one, r=MattN
--HG-- extra : rebase_source : b0da4054ae15276f0b37d951675ff284a54bff3a
This commit is contained in:
Родитель
233484515d
Коммит
9bde498c5b
|
@ -700,7 +700,7 @@ var tests = [
|
|||
onHidden: function (popup) {
|
||||
ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked because it was too soon");
|
||||
ok(this.notifyObj.dismissalCallbackTriggered, "dismissal callback was triggered");
|
||||
},
|
||||
}
|
||||
},
|
||||
{ // Test #24 - test security delay - after delay
|
||||
run: function () {
|
||||
|
@ -723,7 +723,7 @@ var tests = [
|
|||
ok(this.notifyObj.mainActionClicked, "mainAction was clicked after the delay");
|
||||
ok(!this.notifyObj.dismissalCallbackTriggered, "dismissal callback was not triggered");
|
||||
PopupNotifications.buttonDelay = PREF_SECURITY_DELAY_INITIAL;
|
||||
},
|
||||
}
|
||||
},
|
||||
{ // Test #25 - reload removes notification
|
||||
run: function () {
|
||||
|
@ -827,6 +827,37 @@ var tests = [
|
|||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
{ // Test #29 - Existing popup notification shouldn't disappear when adding a dismissed notification
|
||||
run: function () {
|
||||
this.notifyObj1 = new basicNotification();
|
||||
this.notifyObj1.id += "_1";
|
||||
this.notifyObj1.anchorID = "default-notification-icon";
|
||||
this.notification1 = showNotification(this.notifyObj1);
|
||||
},
|
||||
onShown: function (popup) {
|
||||
// Now show a dismissed notification, and check that it doesn't clobber
|
||||
// the showing one.
|
||||
this.notifyObj2 = new basicNotification();
|
||||
this.notifyObj2.id += "_2";
|
||||
this.notifyObj2.anchorID = "geo-notification-icon";
|
||||
this.notifyObj2.options.dismissed = true;
|
||||
this.notification2 = showNotification(this.notifyObj2);
|
||||
|
||||
checkPopup(popup, this.notifyObj1);
|
||||
|
||||
// check that both anchor icons are showing
|
||||
is(document.getElementById("default-notification-icon").getAttribute("showing"), "true",
|
||||
"notification1 anchor should be visible");
|
||||
is(document.getElementById("geo-notification-icon").getAttribute("showing"), "true",
|
||||
"notification2 anchor should be visible");
|
||||
|
||||
dismissNotification(popup);
|
||||
},
|
||||
onHidden: function(popup) {
|
||||
this.notification1.remove();
|
||||
this.notification2.remove();
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -846,8 +877,10 @@ function checkPopup(popup, notificationObj) {
|
|||
ok(notificationObj.shownCallbackTriggered, "shown callback was triggered");
|
||||
|
||||
let notifications = popup.childNodes;
|
||||
is(notifications.length, 1, "only one notification displayed");
|
||||
is(notifications.length, 1, "one notification displayed");
|
||||
let notification = notifications[0];
|
||||
if (!notification)
|
||||
return;
|
||||
let icon = document.getAnonymousElementByAttribute(notification, "class", "popup-notification-icon");
|
||||
if (notificationObj.id == "geolocation") {
|
||||
isnot(icon.boxObject.width, 0, "icon for geo displayed");
|
||||
|
|
|
@ -255,7 +255,7 @@ PopupNotifications.prototype = {
|
|||
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
||||
if (browser == this.tabbrowser.selectedBrowser && fm.activeWindow == this.window) {
|
||||
// show panel now
|
||||
this._update(notification.anchorElement);
|
||||
this._update(notification.anchorElement, true);
|
||||
} else {
|
||||
// Otherwise, update() will display the notification the next time the
|
||||
// relevant tab/window is selected.
|
||||
|
@ -550,8 +550,14 @@ PopupNotifications.prototype = {
|
|||
/**
|
||||
* Updates the notification state in response to window activation or tab
|
||||
* selection changes.
|
||||
*
|
||||
* @param anchor is a XUL element reprensenting the anchor whose notifications
|
||||
* should be shown.
|
||||
* @param dismissShowing if true, dismiss any currently visible notifications
|
||||
* if there are no notifications to show. Otherwise,
|
||||
* currently displayed notifications will be left alone.
|
||||
*/
|
||||
_update: function PopupNotifications_update(anchor) {
|
||||
_update: function PopupNotifications_update(anchor, dismissShowing = false) {
|
||||
if (this.iconBox) {
|
||||
// hide icons of the previous tab.
|
||||
this._hideIcons();
|
||||
|
@ -584,9 +590,12 @@ PopupNotifications.prototype = {
|
|||
// Notify observers that we're not showing the popup (useful for testing)
|
||||
this._notify("updateNotShowing");
|
||||
|
||||
// Dismiss the panel if needed. _onPopupHidden will ensure we never call
|
||||
// a dismissal handler on a notification that's been removed.
|
||||
this._dismiss();
|
||||
// Close the panel if there are no notifications to show.
|
||||
// When called from PopupNotifications.show() we should never close the
|
||||
// panel, however. It may just be adding a dismissed notification, in
|
||||
// which case we want to continue showing any existing notifications.
|
||||
if (!dismissShowing)
|
||||
this._dismiss();
|
||||
|
||||
// Only hide the iconBox if we actually have no notifications (as opposed
|
||||
// to not having any showable notifications)
|
||||
|
|
Загрузка…
Ссылка в новой задаче