[firefox-devtools-mcp] Report open alert/confirm/prompt dialogs and the tools that handle them
Categories
(Developer Infrastructure :: Firefox MCP, enhancement, P2)
Tracking
(Not tracked)
People
(Reporter: jdescottes, Assigned: hbenl)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Whiteboard: [webdriver:m22])
Attachments
(1 external file)
Subscribe to browsingContext.userPromptOpened and userPromptClosed. When a dialog is open after a tool call, add a line to the Changes block with its type and message. Example:
- Dialog open: confirm "Leave this page?". Use accept_dialog or dismiss_dialog.
FWIW, Playwright rejects every other tool while a dialog is open. That is out of scope here and can be a follow-up if needed (this is similar to WebDriver classic's behavior).
| Reporter | ||
Comment 1•15 days ago
|
||
Notes from the review of the dialog BiDi migration (Bug 2080970, Bug 2081620). That PR switched unhandledPromptBehavior to "ignore". We are discussing keep the current default until this bug is fixed, so the switch to "ignore" could happen here.
Current default handler:
- With BiDi enabled, Firefox closes every prompt as soon as it opens (UserPromptHandlerManager), in every tab, including tabs the agent never touched. With a regular Firefox profile, this cancels the user's own confirm/prompt dialogs. This is a good reason to switch to "ignore" once agents get notified.
What agents see today with "ignore" and an open dialog (tested with a real Firefox):
- evaluate_script (sync), take_snapshot, get_page_text, screenshot_page and press_key return success. Nothing mentions the dialog.
- An async evaluate_script times out after 5s with a message about an infinite loop, because page timers are paused.
- navigate_page closes the dialog without saying so.
- Not tested yet: click_by_uid, close_page, beforeunload prompts.
Things the userPromptOpened data can also fix:
- accept_dialog without promptText on a prompt returns "" instead of the default value. The BiDi spec sets userText to the empty string when it is missing, and Firefox follows the spec. We can send the defaultValue from userPromptOpened when promptText is missing. Classic WebDriver kept the default value.
- accept_dialog with promptText on an alert or confirm ignores the text without any error, but the reply says Accepted: "<text>". With the type from userPromptOpened, the handler can reply correctly or return an error.
- userPromptOpened gives the context, so we could also handle dialogs in tabs other than the selected one.
| Assignee | ||
Updated•15 days ago
|
| Assignee | ||
Comment 2•15 days ago
|
||
Tool calls that open a dialog synchronously don't return until the prompt is closed (tested with click_by_uid and evaluate_script, see this spec issue). I suggest we follow this proposal in the MCP: return early from the tool call with a message
- Dialog opened while tool was running: confirm "Leave this page?". Use accept_dialog or dismiss_dialog.
| Reporter | ||
Comment 3•15 days ago
|
||
(In reply to Holger Benl [:hbenl] from comment #2)
Tool calls that open a dialog synchronously don't return until the prompt is closed (tested with
click_by_uidandevaluate_script, see this spec issue). I suggest we follow this proposal in the MCP: return early from the tool call with a message
- Dialog opened while tool was running: confirm "Leave this page?". Use accept_dialog or dismiss_dialog.
Makes sense. Hopefully the heuristics to detect that the prompt open is indeed related to a specific command will not be too flaky.
Comment 4•14 days ago
|
||
(via GitHub webhook, authenticated as firefox-devtools-mcp@bots.tld)
| Assignee | ||
Comment 5•13 days ago
|
||
Opened Bug 2090076 for returning early from tool calls that get blocked.
Description
•