Skip to content

Commit

Permalink
Support user prompt handlers for BiDi sessions
Browse files Browse the repository at this point in the history
The key part of this is that with BiDi HTML calls into the spec when
it's going to show a prompt. So at that point we can see if there's a
handler defined, and if so return the handler to HTML.

All the actual logic to handle the dialogs ends up in the HTML spec.

From the BiDi point of view, the intended lifecycle is that you always
get the session.userPromptOpened and session.userPromptClosed events,
even if the prompt is automatically handled. But the
session.UserPromptOpened event gets a new `handler` property that
tells you whether the prompt will be automatically handled; if this is
set to "none" the automation has to send a session.handleUserPrompt
command (or wait for the prompt to be dismissed by the user).
  • Loading branch information
jgraham committed Mar 8, 2024
1 parent c99dd87 commit b6a4e7d
Showing 1 changed file with 47 additions and 6 deletions.
53 changes: 47 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
text: window open steps; url: window-object.html#window-open-steps
text: worker event loop; url: webappapis.html#worker-event-loop-2
text: worklet global scopes; url:worklets.html#concept-document-worklet-global-scopes
spec: INFRA; urlPrefix: https://infra.spec.whatwg.org/
type: dfn
text: convert a JSON-derived JavaScript value to an Infra value; url: convert-a-json-derived-javascript-value-to-an-infra-value
spec: RESOURCE-TIMING; urlPrefix: https://w3c.github.io/resource-timing/
type: dfn
text: convert fetch timestamp; url: dfn-convert-fetch-timestamp
Expand Down Expand Up @@ -480,7 +483,7 @@ WebDriver BiDi extends the [=/session=] concept from [[WEBDRIVER|WebDriver]].
A [=/session=] has a <dfn>BiDi flag</dfn>, which is false unless otherwise
stated.

A <dfn>BiDi session</dfn> is a [=/session=] which has the [=BiDi flag=]
A <dfn export>BiDi session</dfn> is a [=/session=] which has the [=BiDi flag=]
set to true.

<div algorithm>
Expand Down Expand Up @@ -1550,7 +1553,7 @@ session.CapabilityRequest = {
? browserVersion: text,
? platformName: text,
? proxy: session.ProxyConfiguration,
? webSocketUrl: bool,
? userPromptHandler: session.UserPromptHandler,
Extensible
};
</pre>
Expand Down Expand Up @@ -1641,6 +1644,28 @@ session.SystemProxyConfiguration = (

</pre>

#### The session.UserPromptHandler Type #### {#type-session-UserPromptHandler}

[=Remote end definition=] and [=local end definition=]

<pre class="cddl remote-cddl local-cddl">
session.UserPromptHandler = session.UserPromptHandlerType /
session.UserPromptHandlerConfiguration;

session.UserPromptHandlerType = "accept" / "dismiss" / "ignore";

session.UserPromptHandlerConfiguration = {
? alert: session.UserPromptHandlerType,
? beforeUnload: session.UserPromptHandlerType,
? confirm: session.UserPromptHandlerType,
? default: session.UserPromptHandlerType,
? prompt: session.UserPromptHandlerType,
};
</pre>

The <code>session.UserPromptHandler</code> type represents the configuration of
the user prompt handler.

#### The session.SubscriptionRequest Type #### {#type-session-SubscriptionRequest}

<pre class="cddl remote-cddl">
Expand Down Expand Up @@ -1741,6 +1766,7 @@ This is a [=static command=].
setWindowRect: bool,
userAgent: text,
? proxy: session.ProxyConfiguration,
? userPromptHandler: session.UserPromptHandler,
? webSocketUrl: text,
Extensible
}
Expand All @@ -1760,9 +1786,12 @@ The [=remote end steps=] given |session| and |command parameters| are:

1. Let |flags| be a [=/set=] containing "<code>bidi</code>".

1. Let |capabilities| be the result of [=trying=] to [=process capabilities=]
1. Let |capabilities json| be the result of [=trying=] to [=process capabilities=]
with |command parameters| and |flags|.

1. Let |capabilities| be [=convert a JSON-derived JavaScript value to an Infra
value=] with |capabilities json|.

1. Let |session| be the result of [=trying=] to [=create a session=] with
|capabilities| and |flags|.

Expand Down Expand Up @@ -4436,8 +4465,9 @@ closed</dfn> steps given |window|, |accepted| and optional |user text|

browsingContext.UserPromptOpenedParameters = {
context: browsingContext.BrowsingContext,
type: "alert" / "confirm" / "prompt" / "beforeunload",
handler: "accept" / "dismiss" / "ignore",
message: text,
type: "alert" / "confirm" / "prompt" / "beforeunload",
? defaultValue: text
}
</pre>
Expand All @@ -4453,12 +4483,18 @@ opened</dfn> steps given |window|, |type|, |message|, and optional |default valu

1. Let |context id| be the [=browsing context id=] for |context|.

1. Let |handler configuration| be [=get the prompt handler=] with |type|.

1. Let |handler| be |handler configuration|'s [=prompt handler
configuration/handler=].

1. Let |params| be a [=/map=] matching the
<code>browsingContext.UserPromptOpenedParameters</code> production with the
<code>context</code> field set to |context id|, the <code>type</code> field
set to |type|, the <code>message</code> field set to |message|, and the
set to |type|, the <code>message</code> field set to |message|, the
<code>defaultValue</code> field set to |default value| if |default value| is
not null or omitted otherwise.
not null or omitted otherwise, and the <code>handler</code> field set to
|handler|.

1. Let |body| be a [=/map=] matching the
<code>browsingContext.UserPromptOpened</code> production, with the
Expand All @@ -4471,6 +4507,10 @@ opened</dfn> steps given |window|, |type|, |message|, and optional |default valu

1. [=Emit an event=] with |session| and |body|.

1. If |handler| is "<code>ignore</code>", set handler to "<code>none</code>".

1. Return |handler|

</div>

## The network Module ## {#module-network}
Expand Down Expand Up @@ -10538,6 +10578,7 @@ The [=remote end steps=] given |session| and |command parameters| are:

</div>


# Patches to Other Specifications # {#patches}

This specification requires some changes to external specifications to provide the necessary
Expand Down

0 comments on commit b6a4e7d

Please sign in to comment.