зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1670255 - Show default notification bar on permanent private windows. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D93591
This commit is contained in:
Родитель
19c21c31d2
Коммит
131e1f04be
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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({
|
||||
|
|
Загрузка…
Ссылка в новой задаче