зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1860172 - Prevent Feature Callout from showing if a dialog or panel is already open. r=omc-reviewers,negin
Differential Revision: https://phabricator.services.mozilla.com/D191796
This commit is contained in:
Родитель
81b41742d8
Коммит
5e8c456621
|
@ -84,6 +84,13 @@ export class _FeatureCalloutBroker {
|
|||
return false;
|
||||
}
|
||||
const win = browser.ownerGlobal;
|
||||
// Avoid showing feature callouts if a dialog or panel is showing.
|
||||
if (
|
||||
win.gDialogBox?.dialog ||
|
||||
[...win.document.querySelectorAll("panel")].some(p => p.state === "open")
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const currentCallout = this.#calloutMap.get(win);
|
||||
// If a custom callout was previously showing, but is no longer showing,
|
||||
// tear down the FeatureCallout instance. We avoid tearing them down when
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
const { CustomizableUITestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/CustomizableUITestUtils.sys.mjs"
|
||||
);
|
||||
|
||||
const PDF_TEST_URL =
|
||||
"https://example.com/browser/browser/components/newtab/test/browser/file_pdf.PDF";
|
||||
|
@ -457,6 +459,42 @@ add_task(async function triggered_feature_tour_with_custom_pref() {
|
|||
);
|
||||
});
|
||||
|
||||
add_task(async function callout_not_shown_if_dialog_open() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["prompts.windowPromptSubDialog", true]],
|
||||
});
|
||||
|
||||
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
let dialogPromise = BrowserTestUtils.promiseAlertDialogOpen();
|
||||
// Avoid blocking the test on the (sync) alert by sticking it in a timeout:
|
||||
setTimeout(() => Services.prompt.alert(win, "Some title", "some message"), 0);
|
||||
await dialogPromise;
|
||||
|
||||
let rv = await FeatureCalloutBroker.showFeatureCallout(
|
||||
win.gBrowser.selectedBrowser,
|
||||
testMessage.message
|
||||
);
|
||||
ok(!rv, "Feature callout not shown when a dialog is open in the same window");
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
add_task(async function callout_not_shown_if_panel_open() {
|
||||
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
const gCUITestUtils = new CustomizableUITestUtils(win);
|
||||
await gCUITestUtils.openMainMenu();
|
||||
|
||||
let rv = await FeatureCalloutBroker.showFeatureCallout(
|
||||
win.gBrowser.selectedBrowser,
|
||||
testMessage.message
|
||||
);
|
||||
ok(!rv, "Feature callout not shown when a panel is open in the same window");
|
||||
|
||||
await gCUITestUtils.hideMainMenu();
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
add_task(async function feature_callout_renders_in_browser_chrome_for_pdf() {
|
||||
const sandbox = sinon.createSandbox();
|
||||
const sendTriggerStub = sandbox.stub(ASRouter, "sendTriggerMessage");
|
||||
|
|
Загрузка…
Ссылка в новой задаче