summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/tabPrompts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /browser/base/content/test/tabPrompts
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/tabPrompts')
-rw-r--r--browser/base/content/test/tabPrompts/browser_beforeunload_urlbar.js30
-rw-r--r--browser/base/content/test/tabPrompts/browser_confirmFolderUpload.js2
-rw-r--r--browser/base/content/test/tabPrompts/browser_contentOrigins.js6
-rw-r--r--browser/base/content/test/tabPrompts/browser_multiplePrompts.js72
-rw-r--r--browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js113
5 files changed, 9 insertions, 214 deletions
diff --git a/browser/base/content/test/tabPrompts/browser_beforeunload_urlbar.js b/browser/base/content/test/tabPrompts/browser_beforeunload_urlbar.js
index 52044b5874..1466e9ca86 100644
--- a/browser/base/content/test/tabPrompts/browser_beforeunload_urlbar.js
+++ b/browser/base/content/test/tabPrompts/browser_beforeunload_urlbar.js
@@ -9,11 +9,6 @@ const TEST_ROOT = getRootDirectory(gTestPath).replace(
"http://example.com"
);
-const CONTENT_PROMPT_SUBDIALOG = Services.prefs.getBoolPref(
- "prompts.contentPromptSubDialog",
- false
-);
-
add_task(async function test_beforeunload_stay_clears_urlbar() {
await SpecialPowers.pushPrefEnv({
set: [["dom.require_user_interaction_for_beforeunload", false]],
@@ -27,27 +22,10 @@ add_task(async function test_beforeunload_stay_clears_urlbar() {
gURLBar.value = inputValue.slice(0, -1);
EventUtils.sendString(inputValue.slice(-1));
- if (CONTENT_PROMPT_SUBDIALOG) {
- let promptOpenedPromise =
- BrowserTestUtils.promiseAlertDialogOpen("cancel");
- EventUtils.synthesizeKey("VK_RETURN");
- await promptOpenedPromise;
- await TestUtils.waitForTick();
- } else {
- let promptOpenedPromise = TestUtils.topicObserved(
- "tabmodal-dialog-loaded"
- );
- EventUtils.synthesizeKey("VK_RETURN");
- await promptOpenedPromise;
- let promptElement = browser.parentNode.querySelector("tabmodalprompt");
-
- // Click the cancel button
- promptElement.querySelector(".tabmodalprompt-button1").click();
- await TestUtils.waitForCondition(
- () => promptElement.parentNode == null,
- "tabprompt should be removed"
- );
- }
+ let promptOpenedPromise = BrowserTestUtils.promiseAlertDialogOpen("cancel");
+ EventUtils.synthesizeKey("VK_RETURN");
+ await promptOpenedPromise;
+ await TestUtils.waitForTick();
// Can't just compare directly with TEST_URL because the URL may be trimmed.
// Just need it to not be the example.org thing we typed in.
diff --git a/browser/base/content/test/tabPrompts/browser_confirmFolderUpload.js b/browser/base/content/test/tabPrompts/browser_confirmFolderUpload.js
index 62b0ed4f2b..52596095c4 100644
--- a/browser/base/content/test/tabPrompts/browser_confirmFolderUpload.js
+++ b/browser/base/content/test/tabPrompts/browser_confirmFolderUpload.js
@@ -88,7 +88,7 @@ async function testUploadPrompt(confirmUpload) {
await ContentTask.spawn(browser, { path }, args => {
let MockFilePicker = content.SpecialPowers.MockFilePicker;
MockFilePicker.init(
- content,
+ content.browsingContext,
"A Mock File Picker",
content.SpecialPowers.Ci.nsIFilePicker.modeGetFolder
);
diff --git a/browser/base/content/test/tabPrompts/browser_contentOrigins.js b/browser/base/content/test/tabPrompts/browser_contentOrigins.js
index 10c8809490..2bf4ba6039 100644
--- a/browser/base/content/test/tabPrompts/browser_contentOrigins.js
+++ b/browser/base/content/test/tabPrompts/browser_contentOrigins.js
@@ -129,11 +129,7 @@ async function checkDialog(
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
- set: [
- ["prompts.contentPromptSubDialog", true],
- ["prompts.modalType.httpAuth", Ci.nsIPrompt.MODAL_TYPE_TAB],
- ["prompts.tabChromePromptSubDialog", true],
- ],
+ set: [["prompts.modalType.httpAuth", Ci.nsIPrompt.MODAL_TYPE_TAB]],
});
});
diff --git a/browser/base/content/test/tabPrompts/browser_multiplePrompts.js b/browser/base/content/test/tabPrompts/browser_multiplePrompts.js
index 597b7dfd6f..65c8b3eff4 100644
--- a/browser/base/content/test/tabPrompts/browser_multiplePrompts.js
+++ b/browser/base/content/test/tabPrompts/browser_multiplePrompts.js
@@ -1,13 +1,7 @@
"use strict";
-const CONTENT_PROMPT_SUBDIALOG = Services.prefs.getBoolPref(
- "prompts.contentPromptSubDialog",
- false
-);
-
/**
- * Goes through a stacked series of dialogs opened with
- * CONTENT_PROMPT_SUBDIALOG set to true, and ensures that
+ * Goes through a stacked series of dialogs and ensures that
* the oldest one is front-most and has the right type. It
* then closes the oldest to newest dialog.
*
@@ -58,64 +52,6 @@ async function closeDialogs(tab, dialogCount) {
is(dialogs.length, 0, "Dialogs should all be dismissed.");
}
-/**
- * Goes through a stacked series of tabprompt modals opened with
- * CONTENT_PROMPT_SUBDIALOG set to false, and ensures that
- * the oldest one is front-most and has the right type. It also
- * ensures that the other tabprompt modals are hidden. It
- * then closes the oldest to newest dialog.
- *
- * @param {Element} tab The <tab> that has had tabprompt modals opened
- * for it.
- * @param {Number} promptCount How many modals we expected to have been
- * opened.
- *
- * @return {Promise}
- * @resolves {undefined} Once the modals have all been closed.
- */
-async function closeTabModals(tab, promptCount) {
- let promptElementsCount = promptCount;
- while (promptElementsCount--) {
- let promptElements =
- tab.linkedBrowser.parentNode.querySelectorAll("tabmodalprompt");
- is(
- promptElements.length,
- promptElementsCount + 1,
- "There should be " + (promptElementsCount + 1) + " prompt(s)."
- );
- // The oldest should be the first.
- let i = 0;
-
- for (let promptElement of promptElements) {
- let prompt = tab.linkedBrowser.tabModalPromptBox.getPrompt(promptElement);
- let expectedType = ["alert", "prompt", "confirm"][i % 3];
- is(
- prompt.Dialog.args.text,
- expectedType + " countdown #" + i,
- "The #" + i + " alert should be labelled as such."
- );
- if (i !== promptElementsCount) {
- is(prompt.element.hidden, true, "This prompt should be hidden.");
- i++;
- continue;
- }
-
- is(prompt.element.hidden, false, "The last prompt should not be hidden.");
- prompt.onButtonClick(0);
-
- // The click is handled async; wait for an event loop turn for that to
- // happen.
- await new Promise(function (resolve) {
- Services.tm.dispatchToMainThread(resolve);
- });
- }
- }
-
- let promptElements =
- tab.linkedBrowser.parentNode.querySelectorAll("tabmodalprompt");
- is(promptElements.length, 0, "Prompts should all be dismissed.");
-}
-
/*
* This test triggers multiple alerts on one single tab, because it"s possible
* for web content to do so. The behavior is described in bug 1266353.
@@ -161,11 +97,7 @@ add_task(async function () {
await promptsOpenedPromise;
- if (CONTENT_PROMPT_SUBDIALOG) {
- await closeDialogs(tab, PROMPTCOUNT);
- } else {
- await closeTabModals(tab, PROMPTCOUNT);
- }
+ await closeDialogs(tab, PROMPTCOUNT);
BrowserTestUtils.removeTab(tab);
});
diff --git a/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js b/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js
index 6b116b71f9..2fa3752881 100644
--- a/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js
+++ b/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js
@@ -22,118 +22,7 @@ registerCleanupFunction(function () {
* the user to enable this automatically re-selecting. We then check that
* checking the checkbox does actually enable that behaviour.
*/
-add_task(async function test_old_modal_ui() {
- // We're intentionally testing the old modal mechanism, so disable the new one.
- await SpecialPowers.pushPrefEnv({
- set: [["prompts.contentPromptSubDialog", false]],
- });
-
- let firstTab = gBrowser.selectedTab;
- // load page that opens prompt when page is hidden
- let openedTab = await BrowserTestUtils.openNewForegroundTab(
- gBrowser,
- pageWithAlert,
- true
- );
- let openedTabGotAttentionPromise = BrowserTestUtils.waitForAttribute(
- "attention",
- openedTab
- );
- // switch away from that tab again - this triggers the alert.
- await BrowserTestUtils.switchTab(gBrowser, firstTab);
- // ... but that's async on e10s...
- await openedTabGotAttentionPromise;
- // check for attention attribute
- is(
- openedTab.hasAttribute("attention"),
- true,
- "Tab with alert should have 'attention' attribute."
- );
- ok(!openedTab.selected, "Tab with alert should not be selected");
-
- // switch tab back, and check the checkbox is displayed:
- await BrowserTestUtils.switchTab(gBrowser, openedTab);
- // check the prompt is there, and the extra row is present
- let promptElements =
- openedTab.linkedBrowser.parentNode.querySelectorAll("tabmodalprompt");
- is(promptElements.length, 1, "There should be 1 prompt");
- let ourPromptElement = promptElements[0];
- let checkbox = ourPromptElement.querySelector(
- "checkbox[label*='example.com']"
- );
- ok(checkbox, "The checkbox should be there");
- ok(!checkbox.checked, "Checkbox shouldn't be checked");
- // tick box and accept dialog
- checkbox.checked = true;
- let ourPrompt =
- openedTab.linkedBrowser.tabModalPromptBox.getPrompt(ourPromptElement);
- ourPrompt.onButtonClick(0);
- // Wait for that click to actually be handled completely.
- await new Promise(function (resolve) {
- Services.tm.dispatchToMainThread(resolve);
- });
- // check permission is set
- is(
- Services.perms.ALLOW_ACTION,
- PermissionTestUtils.testPermission(pageWithAlert, "focus-tab-by-prompt"),
- "Tab switching should now be allowed"
- );
-
- // Check if the control center shows the correct permission.
- let shown = BrowserTestUtils.waitForEvent(
- window,
- "popupshown",
- true,
- event => event.target == gPermissionPanel._permissionPopup
- );
- gPermissionPanel._identityPermissionBox.click();
- await shown;
- let labelText = SitePermissions.getPermissionLabel("focus-tab-by-prompt");
- let permissionsList = document.getElementById(
- "permission-popup-permission-list"
- );
- let label = permissionsList.querySelector(
- ".permission-popup-permission-label"
- );
- is(label.textContent, labelText);
- gPermissionPanel._permissionPopup.hidePopup();
-
- // Check if the identity icon signals granted permission.
- ok(
- gPermissionPanel._identityPermissionBox.hasAttribute("hasPermissions"),
- "identity-box signals granted permissions"
- );
-
- let openedTabSelectedPromise = BrowserTestUtils.waitForAttribute(
- "selected",
- openedTab,
- "true"
- );
- // switch to other tab again
- await BrowserTestUtils.switchTab(gBrowser, firstTab);
-
- // This is sync in non-e10s, but in e10s we need to wait for this, so yield anyway.
- // Note that the switchTab promise doesn't actually guarantee anything about *which*
- // tab ends up as selected when its event fires, so using that here wouldn't work.
- await openedTabSelectedPromise;
- // should be switched back
- ok(openedTab.selected, "Ta-dah, the other tab should now be selected again!");
-
- // In e10s, with the conformant promise scheduling, we have to wait for next tick
- // to ensure that the prompt is open before removing the opened tab, because the
- // promise callback of 'openedTabSelectedPromise' could be done at the middle of
- // RemotePrompt.openTabPrompt() while 'DOMModalDialogClosed' event is fired.
- await TestUtils.waitForTick();
-
- BrowserTestUtils.removeTab(openedTab);
-});
-
-add_task(async function test_new_modal_ui() {
- // We're intentionally testing the new modal mechanism, so make sure it's enabled.
- await SpecialPowers.pushPrefEnv({
- set: [["prompts.contentPromptSubDialog", true]],
- });
-
+add_task(async function test_modal_ui() {
// Make sure we clear the focus tab permission set in the previous test
PermissionTestUtils.remove(pageWithAlert, "focus-tab-by-prompt");