diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/html/test/browser_bug436200.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/test/browser_bug436200.js')
-rw-r--r-- | dom/html/test/browser_bug436200.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/html/test/browser_bug436200.js b/dom/html/test/browser_bug436200.js new file mode 100644 index 0000000000..7e739c02ad --- /dev/null +++ b/dom/html/test/browser_bug436200.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const kTestPage = "https://example.org/browser/dom/html/test/bug436200.html"; + +async function run_test(shouldShowPrompt, msg) { + let promptShown = false; + + function tabModalObserver(subject) { + promptShown = true; + subject.querySelector(".tabmodalprompt-button0").click(); + } + Services.obs.addObserver(tabModalObserver, "tabmodal-dialog-loaded"); + + function commonDialogObserver(subject) { + let dialog = subject.Dialog; + promptShown = true; + dialog.ui.button0.click(); + } + Services.obs.addObserver(commonDialogObserver, "common-dialog-loaded"); + + let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, kTestPage); + + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { + let form = content.document.getElementById("test_form"); + form.submit(); + }); + Services.obs.removeObserver(tabModalObserver, "tabmodal-dialog-loaded"); + Services.obs.removeObserver(commonDialogObserver, "common-dialog-loaded"); + + is(promptShown, shouldShowPrompt, msg); + BrowserTestUtils.removeTab(tab); +} + +add_task(async function test_prompt() { + await run_test(true, "Should show prompt"); +}); + +add_task(async function test_noprompt() { + await SpecialPowers.pushPrefEnv({ + set: [["security.warn_submit_secure_to_insecure", false]], + }); + await run_test(false, "Should not show prompt"); + await SpecialPowers.popPrefEnv(); +}); + +add_task(async function test_prompt_modal() { + await SpecialPowers.pushPrefEnv({ + set: [ + [ + "prompts.modalType.insecureFormSubmit", + Services.prompt.MODAL_TYPE_WINDOW, + ], + ], + }); + await run_test(true, "Should show prompt"); + await SpecialPowers.popPrefEnv(); +}); |