diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/popupNotifications/browser_reshow_in_background.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/popupNotifications/browser_reshow_in_background.js')
-rw-r--r-- | browser/base/content/test/popupNotifications/browser_reshow_in_background.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/browser/base/content/test/popupNotifications/browser_reshow_in_background.js b/browser/base/content/test/popupNotifications/browser_reshow_in_background.js new file mode 100644 index 0000000000..8dd7e65de0 --- /dev/null +++ b/browser/base/content/test/popupNotifications/browser_reshow_in_background.js @@ -0,0 +1,70 @@ +"use strict"; + +/** + * Tests that when PopupNotifications for background tabs are reshown, they + * don't show up in the foreground tab, but only in the background tab that + * they belong to. + */ +add_task( + async function test_background_notifications_dont_reshow_in_foreground() { + // Our initial tab will be A. Let's open two more tabs B and C, but keep + // A selected. Then, we'll trigger a PopupNotification in C, and then make + // it reshow. + let tabB = BrowserTestUtils.addTab(gBrowser, "https://example.com/"); + await BrowserTestUtils.browserLoaded(tabB.linkedBrowser); + + let tabC = BrowserTestUtils.addTab(gBrowser, "https://example.com/"); + await BrowserTestUtils.browserLoaded(tabC.linkedBrowser); + + let seenEvents = []; + + let options = { + dismissed: false, + eventCallback(popupEvent) { + seenEvents.push(popupEvent); + }, + }; + + let notification = PopupNotifications.show( + tabC.linkedBrowser, + "test-notification", + "", + "geo-notification-icon", + null, + null, + options + ); + Assert.deepEqual(seenEvents, [], "Should have seen no events yet."); + + await BrowserTestUtils.switchTab(gBrowser, tabB); + Assert.deepEqual(seenEvents, [], "Should have seen no events yet."); + + notification.reshow(); + Assert.deepEqual(seenEvents, [], "Should have seen no events yet."); + + let panelShown = BrowserTestUtils.waitForEvent( + PopupNotifications.panel, + "popupshown" + ); + await BrowserTestUtils.switchTab(gBrowser, tabC); + await panelShown; + + Assert.equal(seenEvents.length, 2, "Should have seen two events."); + Assert.equal( + seenEvents[0], + "showing", + "Should have said popup was showing." + ); + Assert.equal(seenEvents[1], "shown", "Should have said popup was shown."); + + let panelHidden = BrowserTestUtils.waitForEvent( + PopupNotifications.panel, + "popuphidden" + ); + PopupNotifications.remove(notification); + await panelHidden; + + BrowserTestUtils.removeTab(tabB); + BrowserTestUtils.removeTab(tabC); + } +); |