Skip to content

Commit 3c02257

Browse files
input.fileDialogOpened + unhandledPromptBehavior:file (#883)
This PR implements `input.fileDialogOpened` event and defines `unhandledPromptBehavior` for `file`. It should be accompanied by the following changes: HTML spec: whatwg/html#11030 WebDriver Classic spec: w3c/webdriver#1884 File system access: WICG/file-system-access#452
1 parent bb45477 commit 3c02257

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

index.bs

+89
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ spec: WEBDRIVER; urlPrefix: https://w3c.github.io/webdriver/
112112
text: unable to capture screen; url: dfn-unable-to-capture-screen
113113
text: unknown command; url: dfn-unknown-command
114114
text: unknown error; url: dfn-unknown-error
115+
text: user prompt handler; url: dfn-user-prompt-handler
115116
text: unsupported operation; url: dfn-unsupported-operation
116117
text: web element reference; url: dfn-web-element-reference
117118
text: webdriver-active flag; url: dfn-webdriver-active-flag
@@ -1711,13 +1712,17 @@ session.UserPromptHandler = {
17111712
? beforeUnload: session.UserPromptHandlerType,
17121713
? confirm: session.UserPromptHandlerType,
17131714
? default: session.UserPromptHandlerType,
1715+
? file: session.UserPromptHandlerType,
17141716
? prompt: session.UserPromptHandlerType,
17151717
};
17161718
</pre>
17171719

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

1723+
Note: <code>file</code> handles file picker. "accept" and "dismiss" dismisses
1724+
the picker. "ignore" keeps the picker open.
1725+
17211726
#### The session.UserPromptHandlerType Type #### {#type-session-UserPromptHandlerType}
17221727

17231728
[=Remote end definition=] and [=local end definition=]
@@ -11801,6 +11806,90 @@ The [=remote end steps=] given |session| and |command parameters| are:
1180111806

1180211807
</div>
1180311808

11809+
### Events ### {#module-input-events}
11810+
11811+
#### The input.fileDialogOpened Event #### {#event-input-fileDialogOpened}
11812+
11813+
<dl>
11814+
<dt>Event Type</dt>
11815+
<dd>
11816+
<pre class="cddl local-cddl remote-cddl">
11817+
input.FileDialogOpened = (
11818+
method: "input.fileDialogOpened",
11819+
params: input.FileDialogInfo
11820+
)
11821+
11822+
input.FileDialogInfo = {
11823+
context: browsingContext.BrowsingContext,
11824+
? element: script.SharedReference,
11825+
multiple: bool,
11826+
}
11827+
</pre>
11828+
</dd>
11829+
</dl>
11830+
11831+
<div algorithm>
11832+
The [=remote end event trigger=] is the
11833+
<dfn export>WebDriver BiDi file dialog opened</dfn> steps, given |element| and optionally
11834+
|file picker options| (default: null):
11835+
11836+
1. Let |navigable| be the |element|'s [=node document=]'s [=/navigable=].
11837+
11838+
1. Let |navigable id| be |navigable|'s [=navigable id=].
11839+
11840+
1. Let |multiple| be <code>false</code>.
11841+
11842+
1. If |element| is not null and |element|'s <{input/multiple}> attribute is set,
11843+
set |multiple| to <code>true</code>.
11844+
11845+
1. If |file picker options| is not null:
11846+
11847+
1. If |file picker options|["<code>multiple</code>"] is true, set |multiple| to
11848+
<code>true</code>.
11849+
11850+
1. Let |related navigables| be a [=/set=] containing |navigable|.
11851+
11852+
1. For each |session| in the [=set of sessions for which an event is enabled=] given
11853+
"<code>input.fileDialogOpened</code>" and |related navigables|:
11854+
11855+
1. Let |params| be a [=/map=] matching the <code>input.FileDialogInfo</code>
11856+
production with the <code>context</code> field set to |navigable id| and
11857+
<code>multiple</code> field set to |multiple|.
11858+
11859+
1. If |element| is not null:
11860+
11861+
1. Let |shared id| be [=get shared id for a node=] with |element| and |session|.
11862+
11863+
1. Set |params|["<code>element</code>"] to |shared id|.
11864+
11865+
1. Let |body| be a [=/map=] matching the <code>input.fileDialogOpened</code>
11866+
production, with the <code>params</code> field set to |params|.
11867+
11868+
1. [=Emit an event=] with |session| and |body|.
11869+
11870+
1. Let |dismissed| be false.
11871+
11872+
1. For each |session| in [=active BiDi sessions=]:
11873+
11874+
1. Let |user prompt handler| be |session|'s [=user prompt handler=].
11875+
11876+
1. If |user prompt handler| is not null:
11877+
11878+
1. Assert |user prompt handler| is a [=/map=].
11879+
11880+
1. If |user prompt handler| [=map/contains=] "<code>file</code>":
11881+
11882+
1. If |user prompt handler|["<code>file</code>"] is not equal to
11883+
"<code>ignore</code>", set |dismissed| to true.
11884+
11885+
1. Otherwise if |user prompt handler| [=map/contains=] "<code>default</code>" and
11886+
|user prompt handler|["<code>default</code>"] is not equal to
11887+
"<code>ignore</code>", set |dismissed| to true.
11888+
11889+
1. Return |dismissed|.
11890+
11891+
</div>
11892+
1180411893

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

0 commit comments

Comments
 (0)