summaryrefslogtreecommitdiffstats
path: root/browser/components/tests/browser/browser_quit_shortcut_warning.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/tests/browser/browser_quit_shortcut_warning.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/tests/browser/browser_quit_shortcut_warning.js')
-rw-r--r--browser/components/tests/browser/browser_quit_shortcut_warning.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/browser/components/tests/browser/browser_quit_shortcut_warning.js b/browser/components/tests/browser/browser_quit_shortcut_warning.js
new file mode 100644
index 0000000000..7bc67d8562
--- /dev/null
+++ b/browser/components/tests/browser/browser_quit_shortcut_warning.js
@@ -0,0 +1,54 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// This test checks that the quit dialog appears correctly when the browser.warnOnQuitShortcut
+// preference is set and the quit keyboard shortcut is pressed.
+add_task(async function test_quit_shortcut() {
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ ["browser.warnOnQuit", true],
+ ["browser.warnOnQuitShortcut", true],
+ ],
+ });
+
+ function checkDialog(dialog) {
+ let dialogElement = dialog.document.getElementById("commonDialog");
+ let acceptLabel = dialogElement.getButton("accept").label;
+ is(acceptLabel.indexOf("Quit"), 0, "dialog label");
+ dialogElement.getButton("cancel").click();
+ }
+
+ let dialogOpened = false;
+ function setDialogOpened() {
+ dialogOpened = true;
+ }
+ Services.obs.addObserver(setDialogOpened, "common-dialog-loaded");
+
+ // Test 1: quit using the shortcut key with the preference enabled.
+ let quitPromise = BrowserTestUtils.promiseAlertDialog("cancel", undefined, {
+ callback: checkDialog,
+ });
+ ok(!canQuitApplication(undefined, "shortcut"), "can quit with dialog");
+
+ ok(dialogOpened, "confirmation prompt should have opened");
+
+ await quitPromise;
+
+ // Test 2: quit without using the shortcut key with the preference enabled.
+ dialogOpened = false;
+ ok(canQuitApplication(undefined, ""), "can quit with no dialog");
+ ok(!dialogOpened, "confirmation prompt should not have opened");
+
+ // Test 3: quit using the shortcut key with the preference disabled.
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.warnOnQuitShortcut", false]],
+ });
+
+ dialogOpened = false;
+ ok(canQuitApplication(undefined, "shortcut"), "can quit with no dialog");
+
+ ok(!dialogOpened, "confirmation prompt should not have opened");
+ Services.obs.removeObserver(setDialogOpened, "common-dialog-loaded");
+
+ await SpecialPowers.popPrefEnv();
+});