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

Add an autofill module #706

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
155 changes: 155 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ spec: WEBDRIVER; urlPrefix: https://w3c.github.io/webdriver/
text: input cancel list; url: dfn-input-cancel-list
text: intermediary node; url: dfn-intermediary-node
text: invalid argument; url: dfn-invalid-argument
text: invalid element state; url: dfn-invalid-element-state
text: invalid selector; url: dfn-invalid-selector
text: invalid session id; url: dfn-invalid-session-id
text: is element origin; url: dfn-is-element-origin
Expand Down Expand Up @@ -188,6 +189,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
text: close; url: window-object.html#close-a-browsing-context
text: disabled; url: form-control-infrastructure.html#concept-fe-disabled
text: File Upload state; url: input.html#file-upload-state-(type=file)
text: form-associated element; url: forms.html#form-associated-element
text: confirm; url: timers-and-user-prompts.html#dom-confirm
text: context mode; url: /canvas.html#offscreencanvas-context-mode
text: create a classic script; url: webappapis.html#creating-a-classic-script
Expand Down Expand Up @@ -282,6 +284,9 @@ spec: CORE-AAM; urlPrefix:https://www.w3.org/TR/core-aam-1.2
spec: MEDIAQUERIES4; urlPrefix: https://drafts.csswg.org/mediaqueries-4/
type: dfn
text: resolution media feature; url: #resolution
spec:infra; urlPrefix: https://infra.spec.whatwg.org/
yoavweiss marked this conversation as resolved.
Show resolved Hide resolved
type:dfn;
text:user agent
</pre>

<pre class="biblio">
Expand Down Expand Up @@ -632,6 +637,7 @@ with the following additional codes:
<pre class="cddl local-cddl">
ErrorCode = "invalid argument" /
"invalid selector" /
"invalid element state" /
"invalid session id" /
"move target out of bounds" /
"no such alert" /
Expand Down Expand Up @@ -10651,6 +10657,155 @@ The [=remote end steps=] given |session| and |command parameters| are:

</div>

## The autofill Module ## {#module-autofill}

The <dfn export for=modules>autofill</dfn> module contains functionality for
saving and triggering autofill.

A [=/browsing context=] has a <dfn>autofill store for testing</dfn>, an
<a>ordered map</a>.

### Definition ### {#module-autofill-definition}

[=remote end definition=]

<pre class="cddl remote-cddl">

InputCommand = (
yoavweiss marked this conversation as resolved.
Show resolved Hide resolved
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
autofill.save //
autofill.trigger
)
</pre>

### Commands ### {#module-autofill-commands}

#### The autofill.save Command #### {#command-autofill-save}

The <dfn export for=commands>autofill.save</dfn> command saves a set of field
name values to the [=/browsing context=]'s [=autofill store for testing=].

<dl>
<dt>Command Type</dt>
<dd>
<pre class="cddl remote-cddl">
autofill.save = (
method: "autofill.save",
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
params: autofill.saveParameters
)

autofill.saveParameters = {
context: browsingContext.BrowsingContext,
fields: [*autofill.field]
yoavweiss marked this conversation as resolved.
Show resolved Hide resolved
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
}

autofill.field = (
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
name: tstr,
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
value: tstr
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
)
</pre>
</dd>
<dt>Return Type</dt>
<dd>
<pre class="cddl">
EmptyResult
</pre>
</dd>
</dl>

<div algorithm="remote end steps for autofill.save">

The [=remote end steps=] with <var ignore="">session</var> 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 |store| be |context|'s [=autofill store for testing=].

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

1. For each |field| in |fields|:

1. Let |name| be |field|'s <code>name</code>.

1. Let |value| be |field|'s <code>value</code>.

1. Set |store|[|name|] to |value|.

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

</div>

#### The autofill.trigger Command #### {#command-autofill-trigger}

The <dfn export for=commands>autofill.trigger</dfn> command triggers autofill
on a particular form field using the [=/browsing context=]'s [=autofill
store for testing=].

<dl>
<dt>Command Type</dt>
<dd>
<pre class="cddl remote-cddl">
autofill.trigger = (
method: "autofill.trigger",
params: autofill.triggerParameters
)

autofill.triggerParameters = {
context: browsingContext.BrowsingContext,
element: script.SharedReference
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
}
</pre>
</dd>
<dt>Return Type</dt>
<dd>
<pre class="cddl">
EmptyResult
</pre>
</dd>
</dl>

<div algorithm="remote end steps for autofill.trigger">

The [=remote end steps=] with |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|' [=realm execution context=]'s
Realm component.

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

1. Let |element| be the result of [=trying=] to [=deserialize remote reference=]
with the |element id|, |realm|, and |session|.

1. Let |store| be |context|'s [=autofill store for testing=].

1. If |element| is not a [=form-associated element=] or |element|'s [=form owner=] is
yoavweiss marked this conversation as resolved.
Show resolved Hide resolved
null, return an [=error=] with [=error code=] [=invalid element state=].

1. The [=user agent=] should [=autofill=] |element| and |element|'s [=form
yoavweiss marked this conversation as resolved.
Show resolved Hide resolved
owner=], while taking into account the contents of |store|.

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

</div>

# Patches to Other Specifications # {#patches}

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