diff --git a/browser/actors/AboutNewTabChild.jsm b/browser/actors/AboutNewTabChild.jsm index dd0138a81cc0..870087c3175a 100644 --- a/browser/actors/AboutNewTabChild.jsm +++ b/browser/actors/AboutNewTabChild.jsm @@ -84,12 +84,19 @@ class AboutNewTabChild extends JSWindowActorChild { (event.type == "pageshow" || event.type == "visibilitychange") && // The default browser notification shouldn't be shown on about:welcome // since we don't want to distract from the onboarding wizard. - !this.contentWindow.location.pathname.includes("welcome") && - // Don't show the notification in private windows since it is expected - // to have very little opt-in here. - !PrivateBrowsingUtils.isContentWindowPrivate(this.contentWindow) + !this.contentWindow.location.pathname.includes("welcome") ) { - if (this.document.visibilityState == "visible") { + // Don't show the notification in non-permanent private windows + // since it is expected to have very little opt-in here. + let contentWindowPrivate = PrivateBrowsingUtils.isContentWindowPrivate( + this.contentWindow + ); + if ( + this.document.visibilityState == "visible" && + (!contentWindowPrivate || + (contentWindowPrivate && + PrivateBrowsingUtils.permanentPrivateBrowsing)) + ) { this.sendAsyncMessage("DefaultBrowserNotification"); } } diff --git a/browser/base/content/test/about/browser_aboutNewTab_defaultBrowserNotification.js b/browser/base/content/test/about/browser_aboutNewTab_defaultBrowserNotification.js index 8adc3d88bb30..9c5a0d2e0abc 100644 --- a/browser/base/content/test/about/browser_aboutNewTab_defaultBrowserNotification.js +++ b/browser/base/content/test/about/browser_aboutNewTab_defaultBrowserNotification.js @@ -191,6 +191,45 @@ add_task(async function notification_not_displayed_on_private_window() { ); }); +add_task(async function notification_displayed_on_perm_private_window() { + SpecialPowers.pushPrefEnv({ + set: [["browser.privatebrowsing.autostart", true]], + }); + let privateWin = await BrowserTestUtils.openNewBrowserWindow({ + private: true, + }); + await test_with_mock_shellservice( + { win: privateWin, isDefault: false }, + async function() { + let tab = await BrowserTestUtils.openNewForegroundTab({ + gBrowser: privateWin.gBrowser, + opening: "about:newtab", + waitForLoad: false, + }); + ok( + PrivateBrowsingUtils.isBrowserPrivate( + privateWin.gBrowser.selectedBrowser + ), + "Browser should be private" + ); + let notification = await TestUtils.waitForCondition( + () => + tab.linkedBrowser && + gBrowser.getNotificationBox(tab.linkedBrowser) && + gBrowser.getNotificationBox(tab.linkedBrowser).currentNotification, + "waiting for notification" + ); + ok(notification, "A notification should be shown on the new tab page"); + is( + notification.getAttribute("value"), + "default-browser", + "Notification should be default browser" + ); + await BrowserTestUtils.closeWindow(privateWin); + } + ); +}); + add_task(async function clicking_dismiss_disables_default_browser_checking() { await test_with_mock_shellservice({ isDefault: false }, async function() { let firstTab = await BrowserTestUtils.openNewForegroundTab({