зеркало из https://github.com/mozilla/gecko-dev.git
Bug 825723 - Popup notification anchor disappears when a notification with the same ID is re-added in a background tab. r=gavin
This commit is contained in:
Родитель
f775e73ec4
Коммит
132e8ce7eb
|
@ -727,30 +727,68 @@ var tests = [
|
|||
},
|
||||
{ // Test #25 - location change in background tab removes notification
|
||||
run: function () {
|
||||
this.oldSelectedTab = gBrowser.selectedTab;
|
||||
this.newTab = gBrowser.addTab("about:blank");
|
||||
gBrowser.selectedTab = this.newTab;
|
||||
let oldSelectedTab = gBrowser.selectedTab;
|
||||
let newTab = gBrowser.addTab("about:blank");
|
||||
gBrowser.selectedTab = newTab;
|
||||
|
||||
loadURI("http://example.com/", function() {
|
||||
gBrowser.selectedTab = this.oldSelectedTab;
|
||||
let browser = gBrowser.getBrowserForTab(this.newTab);
|
||||
gBrowser.selectedTab = oldSelectedTab;
|
||||
let browser = gBrowser.getBrowserForTab(newTab);
|
||||
|
||||
this.notifyObj = new basicNotification();
|
||||
this.notifyObj.browser = browser;
|
||||
this.notifyObj.options.eventCallback = function (eventName) {
|
||||
let notifyObj = new basicNotification();
|
||||
notifyObj.browser = browser;
|
||||
notifyObj.options.eventCallback = function (eventName) {
|
||||
if (eventName == "removed") {
|
||||
ok(true, "Notification removed in background tab after reloading");
|
||||
executeSoon(function () {
|
||||
gBrowser.removeTab(this.newTab);
|
||||
gBrowser.removeTab(newTab);
|
||||
goNext();
|
||||
}.bind(this));
|
||||
});
|
||||
}
|
||||
}.bind(this);
|
||||
this.notification = showNotification(this.notifyObj);
|
||||
};
|
||||
showNotification(notifyObj);
|
||||
executeSoon(function () {
|
||||
browser.reload();
|
||||
});
|
||||
}.bind(this));
|
||||
});
|
||||
}
|
||||
},
|
||||
{ // Test #26 - Popup notification anchor shouldn't disappear when a notification with the same ID is re-added in a background tab
|
||||
run: function () {
|
||||
loadURI("http://example.com/", function () {
|
||||
let originalTab = gBrowser.selectedTab;
|
||||
let bgTab = gBrowser.addTab("about:blank");
|
||||
gBrowser.selectedTab = bgTab;
|
||||
loadURI("http://example.com/", function () {
|
||||
let anchor = document.createElement("box");
|
||||
anchor.id = "test26-anchor";
|
||||
anchor.className = "notification-anchor-icon";
|
||||
PopupNotifications.iconBox.appendChild(anchor);
|
||||
|
||||
gBrowser.selectedTab = originalTab;
|
||||
|
||||
let fgNotifyObj = new basicNotification();
|
||||
fgNotifyObj.anchorID = anchor.id;
|
||||
fgNotifyObj.options.dismissed = true;
|
||||
let fgNotification = showNotification(fgNotifyObj);
|
||||
|
||||
let bgNotifyObj = new basicNotification();
|
||||
bgNotifyObj.anchorID = anchor.id;
|
||||
bgNotifyObj.browser = gBrowser.getBrowserForTab(bgTab);
|
||||
// show the notification in the background tab ...
|
||||
let bgNotification = showNotification(bgNotifyObj);
|
||||
// ... and re-show it
|
||||
bgNotification = showNotification(bgNotifyObj);
|
||||
|
||||
ok(fgNotification.id, "notification has id");
|
||||
is(fgNotification.id, bgNotification.id, "notification ids are the same");
|
||||
is(anchor.getAttribute("showing"), "true", "anchor still showing");
|
||||
|
||||
fgNotification.remove();
|
||||
gBrowser.removeTab(bgTab);
|
||||
goNext();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
@ -327,7 +327,7 @@ PopupNotifications.prototype = {
|
|||
* The Notification object to remove.
|
||||
*/
|
||||
remove: function PopupNotifications_remove(notification) {
|
||||
let isCurrent = this._currentNotifications.indexOf(notification) != -1;
|
||||
let isCurrent = notification.browser == this.tabbrowser.selectedBrowser;
|
||||
this._remove(notification);
|
||||
|
||||
// update the panel, if needed
|
||||
|
@ -381,7 +381,8 @@ PopupNotifications.prototype = {
|
|||
if (index == -1)
|
||||
return;
|
||||
|
||||
notification.anchorElement.removeAttribute(ICON_ATTRIBUTE_SHOWING);
|
||||
if (notification.browser == this.tabbrowser.selectedBrowser)
|
||||
notification.anchorElement.removeAttribute(ICON_ATTRIBUTE_SHOWING);
|
||||
|
||||
// remove the notification
|
||||
notifications.splice(index, 1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче