Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implement input.fileDialogOpened #568

Closed
wants to merge 16 commits into from
82 changes: 81 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ spec: WEBDRIVER; urlPrefix: https://w3c.github.io/webdriver/
text: unable to capture screen; url: dfn-unable-to-capture-screen
text: unknown command; url: dfn-unknown-command
text: unknown error; url: dfn-unknown-error
text: user prompt handler; url: dfn-user-prompt-handler
text: unsupported operation; url: dfn-unsupported-operation
text: web element reference; url: dfn-web-element-reference
text: webdriver-active flag; url: dfn-webdriver-active-flag
@@ -1711,13 +1712,17 @@ session.UserPromptHandler = {
? beforeUnload: session.UserPromptHandlerType,
? confirm: session.UserPromptHandlerType,
? default: session.UserPromptHandlerType,
? fileDialog: session.UserPromptHandlerType,
? prompt: session.UserPromptHandlerType,
};
</pre>

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

Note: <code>fileDialog</code> handles file picker. "accept" and "dismiss" dismisses
the picker. "ignore" keeps the picker open.

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

[=Remote end definition=] and [=local end definition=]
@@ -2282,7 +2287,7 @@ BrowserResult = (

Each [=/top-level traversable=] is associated with a single <dfn>client
window</dfn> which represents a rectangular area containing the
<a spec=css22>viewport</a> that will be used to render that [=/top-level
<a spec=css2>viewport</a> that will be used to render that [=/top-level
Copy link
Contributor

Choose a reason for hiding this comment

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

My local build didn't work with css22 for whatever reason.

traversable=]'s [=active document=] when its [=visibility state=] is
"<code>visible</code>", as well as any browser-specific user interface elements
associated with displaying the traversable (e.g. any URL bar, toolbars, or OS
@@ -11705,6 +11710,81 @@ The [=remote end steps=] given |session| and |command parameters| are:

</div>

### Events ### {#module-input-events}

#### The input.fileDialogOpened Event #### {#event-input-fileDialogOpened}

<dl>
<dt>Event Type</dt>
<dd>
<pre class="cddl local-cddl remote-cddl">
input.FileDialogOpened = (
method: "input.fileDialogOpened",
params: input.FileDialogInfo
)

input.FileDialogInfo = {
context: browsingContext.BrowsingContext,
element: script.SharedReference,
multiple: bool,
}
</pre>
</dd>
</dl>

<div algorithm>
The [=remote end event trigger=] is the
<dfn export>WebDriver BiDi file dialog opened</dfn> steps, given |element|.

1. Assert |element| implements {{HTMLInputElement}}.

1. Let |navigable| be the |element|'s [=node document=]'s [=/navigable=].

1. Let |navigable id| be |navigable|'s [=navigable id=].

1. Let |multiple| be <code>true</code> if |element|'s <{input/multiple}> attribute is
set, or <code>false</code> otherwise.

1. Let |related navigables| be a [=/set=] containing |navigable|.

1. For each |session| in the [=set of sessions for which an event is enabled=] given
"<code>input.fileDialogOpened</code>" and |related navigables|:

1. Let |shared id| be [=get shared id for a node=] with |element| and |session|.

1. Let |params| be a [=/map=] matching the <code>input.FileDialogInfo</code>
production with the <code>context</code> field set to |navigable id|, the
<code>element</code> field set to |shared id| and <code>multiple</code> field
set to |multiple|.

1. Let |body| be a [=/map=] matching the <code>input.fileDialogOpened</code>
production, with the <code>params</code> field set to |params|.

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

1. Let |dismissed| be false.

1. 1. For each |session| in [=active BiDI sessions=]:

1. Let |user prompt handler| be |session|'s [=user prompt handler=].

1. If |user prompt handler| is not null:

1. Assert |user prompt handler| is a [=/map=].

1. If |user prompt handler| [=map/contains=] "<code>fileDialog</code>":

1. if |user prompt handler|["<code>fileDialog</code>"] is not equal to
"<code>ignore</code>", set |dismissed| to true.

1. Otherwise if |user prompt handler| [=map/contains=] "<code>default</code>" and
|user prompt handler|["<code>fileDialog</code>"] is not equal to
"<code>ignore</code>", set |dismissed| to true.
Copy link
Contributor

@sadym-chromium sadym-chromium Feb 25, 2025

Choose a reason for hiding this comment

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

Respecting default behavior makes sense, but it is a breaking change, as default of "accept" and "dismiss" starts suppressing file dialog.


1. Return |dismissed|.

</div>


## The webExtension Module ## {#module-webExtension}