Bug 1668507 - Add back accidentally removed call to show the modal dialog when the notificationbar is disabled. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D92134
This commit is contained in:
Jared Wein 2020-10-05 17:36:03 +00:00
Родитель e0a1f1aaec
Коммит f060b775f1
2 изменённых файлов: 35 добавлений и 12 удалений

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

@ -224,10 +224,25 @@ add_task(async function notification_not_shown_on_first_newtab_when_default() {
});
});
add_task(async function modal_notification_shown_when_bar_disabled() {
await test_with_mock_shellservice({ useModal: true }, async function() {
let modalOpenPromise = BrowserTestUtils.promiseAlertDialogOpen("cancel");
// This method is called during startup. Call it now so we don't have to test startup.
let { BrowserGlue } = ChromeUtils.import(
"resource:///modules/BrowserGlue.jsm",
{}
);
BrowserGlue.prototype._maybeShowDefaultBrowserPrompt();
await modalOpenPromise;
});
});
async function test_with_mock_shellservice(options, testFn) {
let oldShellService = window.getShellService;
let mockShellService = {
_isDefault: options.isDefault,
_isDefault: !!options.isDefault,
canSetDesktopBackground() {},
isDefaultBrowserOptOut() {
return false;
@ -248,13 +263,17 @@ async function test_with_mock_shellservice(options, testFn) {
window.getShellService = function() {
return mockShellService;
};
await SpecialPowers.pushPrefEnv({
let prefs = {
set: [
["browser.shell.checkDefaultBrowser", true],
["browser.defaultbrowser.notificationbar", true],
["browser.defaultbrowser.notificationbar", !options.useModal],
["browser.defaultbrowser.notificationbar.checkcount", 0],
],
});
};
if (options.useModal) {
prefs.set.push(["browser.shell.skipDefaultBrowserCheckOnFirstRun", false]);
}
await SpecialPowers.pushPrefEnv(prefs);
// Reset the state so the notification can be shown multiple times in one session
DefaultBrowserNotification.reset();

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

@ -820,7 +820,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
SearchTelemetry: "resource:///modules/SearchTelemetry.jsm",
SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
ShellService: "resource:///modules/ShellService.jsm",
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
TabUnloader: "resource:///modules/TabUnloader.jsm",
TRRRacer: "resource:///modules/TRRPerformance.jsm",
@ -3896,9 +3895,11 @@ BrowserGlue.prototype = {
{}
);
if (willPrompt) {
// Prevent the related notification from appearing if we're
// showing the modal prompt.
// Prevent the related notification from appearing and
// show the modal prompt.
DefaultBrowserNotification.notifyModalDisplayed();
let win = BrowserWindowTracker.getTopWindow();
DefaultBrowserCheck.prompt(win);
}
}
);
@ -4721,9 +4722,9 @@ var DefaultBrowserCheck = {
shouldAsk
);
if (rv == 0) {
ShellService.setAsDefault();
win.getShellService().setAsDefault();
} else if (!shouldAsk.value) {
ShellService.shouldCheckDefaultBrowser = false;
win.getShellService().shouldCheckDefaultBrowser = false;
}
try {
@ -4743,14 +4744,17 @@ var DefaultBrowserCheck = {
* @returns {boolean} True if the default browser check prompt will be shown.
*/
async willCheckDefaultBrowser(isStartupCheck) {
let win = BrowserWindowTracker.getTopWindow();
let shellService = win.getShellService();
// Perform default browser checking.
if (!ShellService) {
if (!shellService) {
return false;
}
let shouldCheck =
!AppConstants.DEBUG &&
ShellService.shouldCheckDefaultBrowser &&
shellService.shouldCheckDefaultBrowser &&
!Services.prefs.getBoolPref(
"browser.defaultbrowser.notificationbar",
false
@ -4787,7 +4791,7 @@ var DefaultBrowserCheck = {
let isDefault = false;
let isDefaultError = false;
try {
isDefault = ShellService.isDefaultBrowser(isStartupCheck, false);
isDefault = shellService.isDefaultBrowser(isStartupCheck, false);
} catch (ex) {
isDefaultError = true;
}