Closed Bug 1884650 Opened 4 months ago Closed 2 months ago

Add support for the new type of "unhandledPromptBehavior" for WebDriver BiDi


(Remote Protocol :: Agent, task, P2)



(firefox128 fixed)

128 Branch
Tracking Status
firefox128 --- fixed


(Reporter: whimboo, Assigned: whimboo)


(Blocks 2 open bugs, )


(Whiteboard: [webdriver:m11][webdriver:relnote])


(1 file)

Over on we are going to add a new userPromptHandler capability to the WebDriver session to allow certain prompt handling like beforeunload for WebDriver BiDi. If WebDriver BiDi is not present or this capability is not set, the session needs to fallback to the unhandledPromptBehavior capability.

Component: Marionette → Agent
Whiteboard: [webdriver:m11]
Points: --- → 5
Priority: -- → P2
Assignee: nobody → hskupin
Blocks: 1895738
No longer blocks: 1895738
Depends on: 1895738

Actually the userPromptHandler capability was a mistake and we should still use the unhandledPromptBehavior capability. I fixed that in

Summary: Add support for the new "userPromptHandler" capability → Add support for the new type of "unhandledPromptBehavior" for WebDriver BiDi

I'm also going to remove specific Marionette unit tests for the unhandledPromptBehavior capability that are already present in wdspec tests, but only leave basic checks for the capability.

Blocks: 1563516
Pushed by
[remote] Add support for user prompt handler. r=webdriver-reviewers,jdescottes

Backed out for causing wdspec failures

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | /webdriver/tests/classic/perform_actions/ | test_dismissed_beforeunload - webdriver.error.UnexpectedAlertOpenException: unexpected alert open (500): Unexpected beforeunload dialog detected. Performed handler "dismiss"
Flags: needinfo?(hskupin)

Looks like there is a race condition between closing the opened beforeunload prompt and the alert checks for the next to execute command:

1716378120924	webdriver::server	DEBUG	-> GET /session/890e4672-cd75-4fca-8f7f-4220cc0c63b8/url
1716378121076	RemoteAgent	TRACE	Received observer notification common-dialog-loaded
1716378121077	Marionette	TRACE	Implicitly accepted "beforeunload" prompt
1716378121117	Marionette	DEBUG	0 -> [0,104,"WebDriver:GetCurrentURL",{}]
1716378121126	RemoteAgent	TRACE	Received event DOMModalDialogClosed
1716378121134	Marionette	DEBUG	0 <- [1,104,{"error":"unexpected alert open","message":"Unexpected beforeunload dialog detected. Performed handler \"dismiss\"","stacktrace":"RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\nWebDriverError@chrome://remote/content/shared/webdriver/Er ... iver/Errors.sys.mjs:800:5\nGeckoDriver.prototype._handleUserPrompts@chrome://remote/content/marionette/driver.sys.mjs:2843:11\n","data":{"text":"This page is asking you to confirm that you want to leave — information you’ve entered may not be saved."}},null]
1716378121139	webdriver::server	DEBUG	<- 500 Internal Server Error {"value":{"error":"unexpected alert open","message":"Unexpected beforeunload dialog detected. Pe ... Errors.sys.mjs:800:5\nGeckoDriver.prototype._handleUserPrompts@chrome://remote/content/marionette/driver.sys.mjs:2843:11\n"}}

Maybe we have to special-case this prompt type and wait for the beforeunload prompt got handled before continuing. I'll try to see if I can reproduce by maybe delaying the automatic accepting a bit.

Flags: needinfo?(hskupin)

Ok, so for now I would propose that we actually wait in _handleUserPrompt() until the dialog was closed and then return. This might change again when I implement support for WebDriver BiDi but it can be done in a follow-up bug. I pushed a try build to check that this works:

Pushed by
[remote] Add support for user prompt handler. r=webdriver-reviewers,jdescottes
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
Whiteboard: [webdriver:m11] → [webdriver:m11][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.