diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /toolkit/components/prompts/test | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/prompts/test')
-rw-r--r-- | toolkit/components/prompts/test/PromptTestUtils.sys.mjs | 112 | ||||
-rw-r--r-- | toolkit/components/prompts/test/chromeScript.js | 40 | ||||
-rw-r--r-- | toolkit/components/prompts/test/prompt_common.js | 19 |
3 files changed, 38 insertions, 133 deletions
diff --git a/toolkit/components/prompts/test/PromptTestUtils.sys.mjs b/toolkit/components/prompts/test/PromptTestUtils.sys.mjs index 138c61b189..051763cfa8 100644 --- a/toolkit/components/prompts/test/PromptTestUtils.sys.mjs +++ b/toolkit/components/prompts/test/PromptTestUtils.sys.mjs @@ -6,40 +6,9 @@ * nsIPromptService. */ -import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs"; import { TestUtils } from "resource://testing-common/TestUtils.sys.mjs"; -const kPrefs = {}; - -// Whether prompts with modal type TAB are shown as SubDialog (true) or -// TabModalPrompt (false). -XPCOMUtils.defineLazyPreferenceGetter( - kPrefs, - "tabPromptSubDialogEnabled", - "prompts.tabChromePromptSubDialog", - false -); - -// Whether web content prompts (alert etc.) are shown as SubDialog (true) -// or TabModalPrompt (false) -XPCOMUtils.defineLazyPreferenceGetter( - kPrefs, - "contentPromptSubDialogEnabled", - "prompts.contentPromptSubDialog", - false -); - -function isCommonDialog(modalType) { - return ( - modalType === Services.prompt.MODAL_TYPE_WINDOW || - (kPrefs.tabPromptSubDialogEnabled && - modalType === Services.prompt.MODAL_TYPE_TAB) || - (kPrefs.contentPromptSubDialogEnabled && - modalType === Services.prompt.MODAL_TYPE_CONTENT) - ); -} - export let PromptTestUtils = { /** * Wait for a prompt from nsIPrompt or nsIPromptsService, interact with it and @@ -85,13 +54,7 @@ export let PromptTestUtils = { let promptClosePromise; // Get parent window to listen for prompt close event - let win; - if (isCommonDialog(dialog.args.modalType)) { - win = dialog.ui.prompt?.opener; - } else { - // Tab prompts should always have a parent window - win = dialog.ui.prompt.win; - } + let win = dialog.ui.prompt?.opener; if (win) { promptClosePromise = BrowserTestUtils.waitForEvent( @@ -161,65 +124,50 @@ export let PromptTestUtils = { } } - let topic = isCommonDialog(modalType) - ? "common-dialog-loaded" - : "tabmodal-dialog-loaded"; + let topic = "common-dialog-loaded"; let dialog; await TestUtils.topicObserved(topic, subject => { // If we are not given a browser, use the currently selected browser of the window let browser = parentBrowser || subject.ownerGlobal.gBrowser?.selectedBrowser; - if (isCommonDialog(modalType)) { - // Is not associated with given parent window, skip - if (parentWindow && subject.opener !== parentWindow) { - return false; - } - - // For tab prompts, ensure that the associated browser matches. - if (browser && modalType == Services.prompt.MODAL_TYPE_TAB) { - let dialogBox = parentWindow.gBrowser.getTabDialogBox(browser); - let hasMatchingDialog = dialogBox - .getTabDialogManager() - ._dialogs.some( - d => d._frame?.browsingContext == subject.browsingContext - ); - if (!hasMatchingDialog) { - return false; - } - } + // Is not associated with given parent window, skip + if (parentWindow && subject.opener !== parentWindow) { + return false; + } - if (browser && modalType == Services.prompt.MODAL_TYPE_CONTENT) { - let dialogBox = parentWindow.gBrowser.getTabDialogBox(browser); - let hasMatchingDialog = dialogBox - .getContentDialogManager() - ._dialogs.some( - d => d._frame?.browsingContext == subject.browsingContext - ); - if (!hasMatchingDialog) { - return false; - } + // For tab prompts, ensure that the associated browser matches. + if (browser && modalType == Services.prompt.MODAL_TYPE_TAB) { + let dialogBox = parentWindow.gBrowser.getTabDialogBox(browser); + let hasMatchingDialog = dialogBox + .getTabDialogManager() + ._dialogs.some( + d => d._frame?.browsingContext == subject.browsingContext + ); + if (!hasMatchingDialog) { + return false; } + } - // subject is the window object of the prompt which has a Dialog object - // attached. - dialog = subject.Dialog; - } else { - // subject is the tabprompt dom node - // Get the full prompt object which has the dialog object - let prompt = browser.tabModalPromptBox.getPrompt(subject); - - // Is not associated with given parent browser, skip. - if (!prompt) { + if (browser && modalType == Services.prompt.MODAL_TYPE_CONTENT) { + let dialogBox = parentWindow.gBrowser.getTabDialogBox(browser); + let hasMatchingDialog = dialogBox + .getContentDialogManager() + ._dialogs.some( + d => d._frame?.browsingContext == subject.browsingContext + ); + if (!hasMatchingDialog) { return false; } - - dialog = prompt.Dialog; } + // subject is the window object of the prompt which has a Dialog object + // attached. + dialog = subject.Dialog; + // Not the modalType we're looking for. // For window prompts dialog.args.modalType is undefined. - if (isCommonDialog(modalType) && dialog.args.modalType !== modalType) { + if (dialog.args.modalType !== modalType) { return false; } diff --git a/toolkit/components/prompts/test/chromeScript.js b/toolkit/components/prompts/test/chromeScript.js index 1e71224f6b..9a6bacc8a4 100644 --- a/toolkit/components/prompts/test/chromeScript.js +++ b/toolkit/components/prompts/test/chromeScript.js @@ -8,16 +8,6 @@ const { BrowserTestUtils } = ChromeUtils.importESModule( "resource://testing-common/BrowserTestUtils.sys.mjs" ); -var tabSubDialogsEnabled = Services.prefs.getBoolPref( - "prompts.tabChromePromptSubDialog", - false -); - -var contentPromptSubdialogsEnabled = Services.prefs.getBoolPref( - "prompts.contentPromptSubDialog", - false -); - // Define these to make EventUtils happy. let window = this; let parent = {}; @@ -91,31 +81,15 @@ async function handlePrompt(action, modalType, isSelect) { let ui; let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - if ( - (!contentPromptSubdialogsEnabled && - modalType === Services.prompt.MODAL_TYPE_CONTENT) || - (!tabSubDialogsEnabled && modalType === Services.prompt.MODAL_TYPE_TAB) - ) { - let gBrowser = browserWin.gBrowser; - let promptManager = gBrowser.getTabModalPromptBox(gBrowser.selectedBrowser); - let prompts = promptManager.listPrompts(); - if (!prompts.length) { - return false; // try again in a bit - } + let doc = getDialogDoc(); + if (!doc) { + return false; // try again in a bit + } - ui = prompts[0].Dialog.ui; - checkTabModal(prompts[0], gBrowser.selectedBrowser); + if (isSelect) { + ui = doc; } else { - let doc = getDialogDoc(); - if (!doc) { - return false; // try again in a bit - } - - if (isSelect) { - ui = doc; - } else { - ui = doc.defaultView.Dialog.ui; - } + ui = doc.defaultView.Dialog.ui; } let dialogClosed = BrowserTestUtils.waitForEvent( diff --git a/toolkit/components/prompts/test/prompt_common.js b/toolkit/components/prompts/test/prompt_common.js index 4b3a2262aa..8d583060da 100644 --- a/toolkit/components/prompts/test/prompt_common.js +++ b/toolkit/components/prompts/test/prompt_common.js @@ -21,10 +21,6 @@ var tabSubDialogsEnabled = SpecialPowers.Services.prefs.getBoolPref( "prompts.tabChromePromptSubDialog", false ); -var contentSubDialogsEnabled = SpecialPowers.Services.prefs.getBoolPref( - "prompts.contentPromptSubDialog", - false -); var isSelectDialog = false; var isOSX = "nsILocalFileMac" in SpecialPowers.Ci; var isE10S = SpecialPowers.Services.appinfo.processType == 2; @@ -200,20 +196,7 @@ function checkPromptState(promptState, expectedState) { // XXX check title? OS X has title in content is(promptState.msg, expectedState.msg, "Checking expected message"); - let isOldContentPrompt = - !promptState.isSubDialogPrompt && - modalType === Ci.nsIPrompt.MODAL_TYPE_CONTENT; - - if (isOldContentPrompt && !promptState.showCallerOrigin) { - ok( - promptState.titleHidden, - "The title should be hidden for content prompts opened with tab modal prompt." - ); - } else if ( - isOSX || - promptState.isSubDialogPrompt || - promptState.showCallerOrigin - ) { + if (isOSX || promptState.isSubDialogPrompt || promptState.showCallerOrigin) { ok( !promptState.titleHidden, "Checking title always visible on OS X or when opened with common dialog" |