Bug 1325223 - Focusing the window shouldn't trigger the showing/shown events again on persistent notifications that were never dismissed, r=past.

This commit is contained in:
Florian Quèze 2017-01-20 23:37:48 +01:00
Родитель 173553c4a8
Коммит 3a6e5eb917
2 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@ -178,6 +178,9 @@ var tests = [
{ id: "Test#7",
*run() {
this.oldSelectedTab = gBrowser.selectedTab;
yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
let firstTab = gBrowser.selectedTab;
yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
let shown = waitForNotificationPanel();
@ -186,11 +189,14 @@ var tests = [
this.notification = showNotification(notifyObj);
yield shown;
ok(notifyObj.shownCallbackTriggered, "Should have triggered the shown callback");
ok(notifyObj.shownCallbackTriggered, "Should have triggered the shown event");
ok(notifyObj.showingCallbackTriggered, "Should have triggered the showing event");
// Reset to false so that we can ensure these are not fired a second time.
notifyObj.shownCallbackTriggered = false;
notifyObj.showingCallbackTriggered = false;
yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
let promiseWin = BrowserTestUtils.waitForNewWindow();
gBrowser.replaceTabWithWindow(gBrowser.selectedTab);
gBrowser.replaceTabWithWindow(firstTab);
let win = yield promiseWin;
let anchor = win.document.getElementById("default-notification-icon");
@ -203,7 +209,15 @@ var tests = [
let id = PopupNotifications.panel.firstChild.getAttribute("popupid");
ok(id.endsWith("Test#7"), "Should have found the notification from Test7");
ok(PopupNotifications.isPanelOpen, "Should have shown the popup again after getting back to the window");
ok(PopupNotifications.isPanelOpen,
"Should have kept the popup on the first window");
ok(!notifyObj.dismissalCallbackTriggered,
"Should not have triggered a dismissed event");
ok(!notifyObj.shownCallbackTriggered,
"Should not have triggered a second shown event");
ok(!notifyObj.showingCallbackTriggered,
"Should not have triggered a second showing event");
this.notification.remove();
gBrowser.removeTab(gBrowser.selectedTab);
gBrowser.selectedTab = this.oldSelectedTab;

Просмотреть файл

@ -565,6 +565,8 @@ PopupNotifications.prototype = {
this._onPopupHidden(aEvent);
break;
case "activate":
if (this.isPanelOpen)
break;
case "TabSelect":
let self = this;
// This is where we could detect if the panel is dismissed if the page