Skip to content

Don't serialize a default user prompt handler for BiDi-only sessions - #1975

Open
f3tchcodes wants to merge 1 commit into
w3c:masterfrom
f3tchcodes:bidi-unhandled-prompt-behavior
Open

f3tchcodes wants to merge 1 commit into
w3c:masterfrom
f3tchcodes:bidi-unhandled-prompt-behavior

Conversation

@f3tchcodes

@f3tchcodes f3tchcodes commented Sep 19, 2026 •

Copy link
Copy Markdown

Fixes #1834.

For BiDi-only sessions, when unhandledPromptBehavior isn't provided, serialize the user prompt handler returns "dismiss and notify", which is the Classic WebDriver string format.

This change passes the session flags to the serializer so HTTP sessions keep the current behavior, while BiDi only sessions return {} instead.

{} is valid for BiDi because all fields in UserPromptHandler are optional.


This change is Reviewable


Preview | Diff

@f3tchcodes f3tchcodes changed the title Handle null user prompt handler for BiDi-only sessions fix: handle null user prompt handler for BiDi-only sessions Sep 20, 2026
@f3tchcodes
f3tchcodes force-pushed the bidi-unhandled-prompt-behavior branch from ec191f0 to 1b59771 Compare September 20, 2026 09:56
Comment thread index.html Outdated
<li><p>If <var>flags</var> contains "<code>http</code>", return
"<code>dismiss and notify</code>".

<li><p>Return an empty JSON <a>Object</a>.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the unhandledPromptBehavior capability is optional in session.CapabilityResponse for BiDi we could as well return null here, and then not add it at all. That's probably more the behavior we would expect here. That way we wouldn't have to pass-through the flag at all given that create a session will handle it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I have updated the serializer to return null when there is no user prompt handler and made Create a Session handle the Classic default while omitting the capability for BiDi only sessions.

@f3tchcodes
f3tchcodes force-pushed the bidi-unhandled-prompt-behavior branch from 1b59771 to d5971f2 Compare October 20, 2026 13:29
@f3tchcodes
f3tchcodes requested a review from whimboo October 25, 2026 10:09
@whimboo whimboo changed the title fix: handle null user prompt handler for BiDi-only sessions Don't serialize a default user prompt handler for BiDi-only sessions Oct 27, 2026

@whimboo whimboo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks close. Thank you @f3tchcodes. I've three inline suggestions to make it easier.

We do not have BiDi-only tests yet so we cannot write a proper wdspec test for it.

Comment thread index.html
be <a>serialize the user prompt handler</a>.

<li><p>Set a property on <var>capabilities</var> with the name
<li><p>If <var>flags</var> contains "<code>http</code>", and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just notice that it might actually be better to move this addition into the http only defaults block below. That way we would have all the relevant classic capability defaults at one place.

Comment thread index.html
Comment on lines +2302 to 2305
<li><p>If <var>serialized user prompt handler</var> is not null, set a
property on <var>capabilities</var> with the name
"<code>unhandledPromptBehavior</code>", and the value <var>serialized
user prompt handler</var>.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current wording is not wrong but it might probably be better to only serialize the user prompt handler when it's really needed. In case of http we don't need that, and for BiDi only when it's not null. So we could remove the serialized user prompt handler definition and replacing this paragraph with:

  <li><p>If the <a>user prompt handler</a> is not null, set a property on
   <var>capabilities</var> with the name "<code>unhandledPromptBehavior</code>",
   and the value <a>serialize the user prompt handler</a>.

Comment thread index.html
<ol class=algorithm>
<li><p>If the <a>user prompt handler</a> is null, return
"<code>dismiss and notify</code>".
<li><p>If the <a>user prompt handler</a> is null, return null.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the above changes we would only call this algorithm with a non-null value. So we could remove the line or probably better assert that it's valid.

Suggested change
<li><p>If the <a>user prompt handler</a> is null, return null.
<li><p>Assert: the <a>user prompt handler</a> is not null.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Serialize the user prompt handler" algorithm should probably have a special case for WebDriverBiDi-only session

2 participants