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/tabPrompts/browser_abort_when_in_modal_state.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 '')
-rw-r--r-- | browser/base/content/test/tabPrompts/browser_abort_when_in_modal_state.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/browser/base/content/test/tabPrompts/browser_abort_when_in_modal_state.js b/browser/base/content/test/tabPrompts/browser_abort_when_in_modal_state.js new file mode 100644 index 0000000000..cb3a1f72d6 --- /dev/null +++ b/browser/base/content/test/tabPrompts/browser_abort_when_in_modal_state.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { PromiseTestUtils } = ChromeUtils.importESModule( + "resource://testing-common/PromiseTestUtils.sys.mjs" +); + +/** + * Check that if we're using a window-modal prompt, + * the next synchronous window-internal modal prompt aborts rather than + * leaving us in a deadlock about how to enter modal state. + */ +add_task(async function test_check_multiple_prompts() { + await SpecialPowers.pushPrefEnv({ + set: [["prompts.windowPromptSubDialog", true]], + }); + let container = document.getElementById("window-modal-dialog"); + let dialogPromise = BrowserTestUtils.promiseAlertDialogOpen(); + + let firstDialogClosedPromise = new Promise(resolve => { + // Avoid blocking the test on the (sync) alert by sticking it in a timeout: + setTimeout(() => { + Services.prompt.alertBC( + window.browsingContext, + Ci.nsIPrompt.MODAL_TYPE_WINDOW, + "Some title", + "some message" + ); + resolve(); + }, 0); + }); + let dialogWin = await dialogPromise; + + // Check circumstances of opening. + ok( + !dialogWin.docShell.chromeEventHandler, + "Should not have embedded the dialog." + ); + + PromiseTestUtils.expectUncaughtRejection(/could not be shown/); + let rv = Services.prompt.confirm( + window, + "I should not appear", + "because another prompt was open" + ); + is(rv, false, "Prompt should have been canceled."); + + info("Accepting dialog"); + dialogWin.document.querySelector("dialog").acceptDialog(); + + await firstDialogClosedPromise; + + await BrowserTestUtils.waitForMutationCondition( + container, + { childList: true, attributes: true }, + () => !container.hasChildNodes() && !container.open + ); +}); |