Skip to content

Commit 804e6aa

Browse files
authored
Add input.setFiles (#514)
1 parent e517ae1 commit 804e6aa

File tree

1 file changed

+89
-1
lines changed

1 file changed

+89
-1
lines changed

index.bs

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
199199
text: hidden; url: document-sequences.html#system-visibility-state
200200
text: history handling behavior; url: browsing-the-web.html#history-handling-behavior
201201
text: innerText getter steps; url:dom.html#dom-innertext
202+
text: input type; url: input.html#dom-input-type
202203
text: navigables; url: document-sequences.html#navigables
203204
text: navigation id; url: browsing-the-web.html#navigation-id
204205
text: origin-clean; url: canvas.html#concept-canvas-origin-clean
@@ -209,6 +210,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
209210
text: report an error; url: webappapis.html#report-the-error
210211
text: run the animation frame callbacks; url: imagebitmap-and-animations.html#run-the-animation-frame-callbacks
211212
text: same origin domain; url: browsers.html#same-origin-domain
213+
text: selected files; url: input.html#concept-input-type-file-selected
212214
text: session history entry; url: browsing-the-web.html#session-history-entry
213215
text: session history traversal queue; url: document-sequences.html#tn-session-history-traversal-queue
214216
text: session history; url: history.html#session-history
@@ -219,6 +221,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
219221
text: system visibility state; url: document-sequences.html#system-visibility-state
220222
text: traversable navigable; url:document-sequences.html#traversable-navigable
221223
text: traverse the history by a delta; url: browsing-the-web.html#traverse-the-history-by-a-delta
224+
text: update the file selection; url: input.html#update-the-file-selection
222225
text: visible; url: document-sequences.html#system-visibility-state
223226
text: window open steps; url: window-object.html#window-open-steps
224227
text: worker event loop; url: webappapis.html#worker-event-loop-2
@@ -603,6 +606,9 @@ with the following additional codes:
603606

604607
<dt><dfn>underspecified storage partition</dfn>
605608
<dd>Tried to interact with data in a storage partition which was not adequately specified.
609+
610+
<dt><dfn>unable to set file input</dfn>
611+
<dd>Tried to set a file input, but failed to do so.
606612
</dl>
607613

608614
<pre class="cddl local-cddl">
@@ -9835,7 +9841,8 @@ simulated user input.
98359841

98369842
InputCommand = (
98379843
input.PerformActions //
9838-
input.ReleaseActions
9844+
input.ReleaseActions //
9845+
input.SetFiles
98399846
)
98409847
</pre>
98419848

@@ -10126,6 +10133,87 @@ The [=remote end steps=] given |session|, and |command parameters| are:
1012610133

1012710134
</div>
1012810135

10136+
#### The input.setFiles Command #### {#command-input-setFiles}
10137+
10138+
The <dfn export for=commands>input.setFiles</dfn> command sets the <code>files</code> property of a given <code>input</code> element with type <code>file</code>
10139+
to a set of file paths.
10140+
10141+
<dl>
10142+
<dt>Command Type</dt>
10143+
<dd>
10144+
<pre class="cddl remote-cddl">
10145+
input.SetFiles = (
10146+
method: "input.setFiles",
10147+
params: input.SetFilesParameters
10148+
)
10149+
10150+
input.SetFilesParameters = {
10151+
context: browsingContext.BrowsingContext,
10152+
element: script.SharedReference,
10153+
files: [*text]
10154+
}
10155+
</pre>
10156+
</dd>
10157+
<dt>Return Type</dt>
10158+
<dd>
10159+
<pre class="cddl">
10160+
EmptyResult
10161+
</pre>
10162+
</dd>
10163+
</dl>
10164+
10165+
<div algorithm="remote end steps for input.setFiles">
10166+
10167+
The [=remote end steps=] given |session| and |command parameters| are:
10168+
10169+
1. Let |context id| be the value of the |command
10170+
parameters|["<code>context</code>"] field.
10171+
10172+
1. Let |context| be the result of [=trying=] to [=get a browsing context=] with
10173+
|context id|.
10174+
10175+
1. Let |document| be |context|'s [=active document=].
10176+
10177+
1. Let |environment settings| be the [=environment settings object=] whose
10178+
[=relevant global object=]'s <a>associated <code>Document</code></a> is
10179+
|document|.
10180+
10181+
1. Let |realm| be |environment settings|'s [=realm execution context=]'s
10182+
Realm component.
10183+
10184+
1. Let |element| be the result of [=trying=] to [=deserialize remote reference=]
10185+
with |command parameters|["<code>element</code>"], |realm|, and |session|.
10186+
10187+
1. If |element| doesn't implement {{Element}}, return [=error=] with [=error code=]
10188+
[=no such element=].
10189+
10190+
1. If |element| doesn't implement {{HTMLInputElement}},
10191+
|element|["<code>type</code>"] is not "file", or
10192+
|element|["<code>disabled</code>"] is true, return [=error=] with [=error
10193+
code=]
10194+
[=unable to set file input=].
10195+
10196+
1. Let |files| be the value of the |command parameters|["<code>files</code>"]
10197+
field.
10198+
10199+
1. Let |selected files| be |element|'s [=selected files=].
10200+
10201+
1. If the [=set/size=] of the [=set/intersection=] of |files| and |selected
10202+
files| is equal to the [=set/size=] of |selected files|, [=queue an element
10203+
task=] on the [=user interaction task source=] given |element| to fire an
10204+
event named <code>cancel</code> at |element|, with the <code>bubbles</code>
10205+
attribute initialized to true.
10206+
10207+
Note: Cancellation in a browser is typically determined by changes in file
10208+
selection. In other words, if there is no change, a "cancel" event is sent.
10209+
10210+
1. Otherwise, [=update the file selection=] for |element| with |files| as the
10211+
user's selection.
10212+
10213+
1. Return [=success=] with data null.
10214+
10215+
</div>
10216+
1012910217
# Patches to Other Specifications # {#patches}
1013010218

1013110219
This specification requires some changes to external specifications to provide the necessary

0 commit comments

Comments
 (0)