Skip to content

Commit

Permalink
Add input.SetFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf-2 committed Nov 8, 2023
1 parent e31b876 commit e24c9dc
Showing 1 changed file with 84 additions and 3 deletions.
87 changes: 84 additions & 3 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
text: hidden; url: document-sequences.html#system-visibility-state
text: history handling behavior; url: browsing-the-web.html#history-handling-behavior
text: innerText getter steps; url:dom.html#dom-innertext
text: input type; url: input.html#dom-input-type
text: navigables; url: document-sequences.html#navigables
text: navigation id; url: browsing-the-web.html#navigation-id
text: origin-clean; url: canvas.html#concept-canvas-origin-clean
Expand All @@ -191,17 +192,20 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
text: report an error; url: webappapis.html#report-the-error
text: run the animation frame callbacks; url: imagebitmap-and-animations.html#run-the-animation-frame-callbacks
text: same origin domain; url: browsers.html#same-origin-domain
text: session history; url: history.html#session-history
text: selected files; url: input.html#concept-input-type-file-selected
text: session history entry; url: browsing-the-web.html#session-history-entry
text: session history traversal queue; url: document-sequences.html#tn-session-history-traversal-queue
text: session history; url: history.html#session-history
text: set up a window environment settings object; url: window-object.html#set-up-a-window-environment-settings-object
text: set up a worker environment settings object; url: workers.html#set-up-a-worker-environment-settings-object
text: set up a worklet environment settings object; url: worklets.html#set-up-a-worklet-environment-settings-object
text: shared worker; url: workers.html#shared-workers
text: show the picker; url: input.html#show-the-picker,-if-applicable
text: system visibility state; url: document-sequences.html#system-visibility-state
text: traversable navigable; url:document-sequences.html#traversable-navigable
text: visible; url: document-sequences.html#system-visibility-state
text: traverse the history by a delta; url: browsing-the-web.html#traverse-the-history-by-a-delta
text: update the file selection; url: input.html#update-the-file-selection
text: visible; url: document-sequences.html#system-visibility-state
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
Expand Down Expand Up @@ -544,6 +548,9 @@ with the following additional codes:

<dt><dfn>unable to close browser</dfn>
<dd>Tried to close the browser, but failed to do so.

<dt><dfn>unable to set file input</dfn>
<dd>Tried to set a file input, but failed to do so.
</dl>

<pre class="cddl local-cddl">
Expand Down Expand Up @@ -9256,7 +9263,8 @@ simulated user input.

InputCommand = (
input.PerformActions //
input.ReleaseActions
input.ReleaseActions //
input.SetFiles
)
</pre>

Expand Down Expand Up @@ -9547,6 +9555,79 @@ The [=remote end steps=] given |session|, and |command parameters| are:

</div>

#### The input.setFiles Command #### {#command-input-setFiles}

The <dfn export for=commands>input.setFiles</dfn> command sets a given file
input with a given set of file paths.

<dl>
<dt>Command Type</dt>
<dd>
<pre class="cddl remote-cddl">
input.SetFiles = (
method: "input.setFiles",
params: input.SetFilesParameters
)

input.SetFilesParameters = {
context: browsingContext.BrowsingContext,
element: script.SharedReference,
files: [*text]
}
</pre>
</dd>
<dt>Return Type</dt>
<dd>
<pre class="cddl">
EmptyResult
</pre>
</dd>
</dl>

<div algorithm="remote end steps for input.setFiles">

The [=remote end steps=] given |session|, and |command parameters| are:

1. Let |context id| be the value of the <code>context</code> field of
|command parameters|.

1. Let |context| be the result of [=trying=] to [=get a browsing context=]
with |context id|.

1. Let |document| be |context|'s [=active document=].

1. Let |environment settings| be the [=environment settings object=] whose
[=relevant global object=]'s <a>associated <code>Document</code></a> is
|document|.

1. Let |realm| be |environment settings|'s [=realm execution context=]'s
Realm component.

1. Let |reference| be the value of the <code>element</code> field of
|command parameters|.

1. Let |files| be the value of the <code>files</code> field of |command
parameters|.

1. Let |selected files| be |element|'s [=selected files=].

1. If the [=set/size=] of the [=set/intersection=] of |files| and |selected files| is
equal to the [=set/size=] of |files|:

1. [=Queue an element task=] on the [=user interaction task source=] given
|element| to fire an event named <code>cancel</code> at |element|, with
the <code>bubbles</code> attribute initialized to true.

1. Return [=success=] with data null.

1. Otherwise, [=update the file selection=] for |element| with |files| as the
user's selection.

1. Return [=success=] with data null.

</div>


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

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

0 comments on commit e24c9dc

Please sign in to comment.