-
Notifications
You must be signed in to change notification settings - Fork 67
Add an autofill module #706
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
base: main
Are you sure you want to change the base?
Changes from all commits
eda8a81
6b787ce
01be87a
309dd38
1db9aa0
1c6e76d
2485d7f
1821ed6
45f5b4b
b9c0ff3
c648b82
e200834
0115db1
92b99fb
a29e2c1
18b152c
3d6fc48
0016aca
4207b82
f9f4dba
8313e42
c73f6fd
8c3d1b1
5b1a397
d4ce738
97ffef9
28c25de
bec6136
556cf8e
6b5310a
77d464e
d75e784
19be917
d4c2429
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,7 @@ spec: WEBDRIVER; urlPrefix: https://w3c.github.io/webdriver/ | |
| text: input cancel list; url: dfn-input-cancel-list | ||
| text: intermediary node; url: dfn-intermediary-nodes | ||
| 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 | ||
|
|
@@ -215,9 +216,12 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/ | |
| text: activation notification; url: interaction.html#activation-notification | ||
| text: active window; url: document-sequences.html#nav-window | ||
| text: alert; url: timers-and-user-prompts.html#dom-alert | ||
| text: autofill; url: form-control-infrastructure.html#autofill | ||
| text: autofill detail tokens; url: form-control-infrastructure.html#autofill-detail-tokens | ||
| text: close; url: document-sequences.html#close-a-top-level-traversable | ||
| 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 | ||
|
|
@@ -263,6 +267,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/ | |
| spec: INFRA; urlPrefix: https://infra.spec.whatwg.org/ | ||
| type: dfn | ||
| text: convert a JSON-derived JavaScript value to an Infra value; url: convert-a-json-derived-javascript-value-to-an-infra-value | ||
| text: values | ||
| spec: RESOURCE-TIMING; urlPrefix: https://w3c.github.io/resource-timing/ | ||
| type: dfn | ||
| text: convert fetch timestamp; url: dfn-convert-fetch-timestamp | ||
|
|
@@ -455,7 +460,8 @@ CommandData = ( | |
| ScriptCommand // | ||
| SessionCommand // | ||
| StorageCommand // | ||
| WebExtensionCommand | ||
| WebExtensionCommand // | ||
| AutofillCommand | ||
| ) | ||
|
|
||
| EmptyParams = { | ||
|
|
@@ -691,6 +697,7 @@ with the following additional codes: | |
| <pre class="cddl" data-cddl-module="local-cddl"> | ||
| ErrorCode = "invalid argument" / | ||
| "invalid selector" / | ||
| "invalid element state" / | ||
| "invalid session id" / | ||
| "invalid web extension" / | ||
| "move target out of bounds" / | ||
|
|
@@ -13616,6 +13623,189 @@ The [=remote end steps=] given |session| and |command parameters| are: | |
|
|
||
| </div> | ||
|
|
||
| ## The autofill Module ## {#module-autofill} | ||
|
|
||
| The <dfn export for=modules>autofill module</dfn> contains functionality for triggering autofill. | ||
|
|
||
| ### Definition ### {#module-autofill-definition} | ||
|
|
||
| {^remote end definition^} | ||
|
|
||
| <pre class="cddl" data-cddl-module="remote-cddl"> | ||
|
|
||
| AutofillCommand = ( | ||
| autofill.Trigger | ||
| ) | ||
| </pre> | ||
|
|
||
| ### Commands ### {#module-autofill-commands} | ||
|
|
||
| #### 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 provided fields. | ||
|
|
||
| <dl> | ||
| <dt>Command Type</dt> | ||
| <dd> | ||
| <pre class="cddl" data-cddl-module="remote-cddl"> | ||
| autofill.Trigger = ( | ||
| method: "autofill.trigger", | ||
| params: autofill.TriggerParameters | ||
| ) | ||
|
|
||
| autofill.TriggerParameters = { | ||
| context: browsingContext.BrowsingContext, | ||
| element: script.SharedReference, | ||
| ? card: autofill.Card, | ||
| ? address: autofill.Address | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about separate billing and shipping addresses? I'm hesitant to associate specific datas with the 'trigger' request because of complications like this. As far as I can tell, there is no way in the autofill module flow, where a test would simulate filling two separate addresses in a meaningful way. |
||
| } | ||
|
|
||
| autofill.Field = { | ||
| name: autofill.FieldName, | ||
| value: text | ||
| } | ||
|
|
||
| autofill.Card = { | ||
| number: text, | ||
| name: text, | ||
| expiryMonth: text, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is there no credit card type field here, but it's in the FieldToken list? I'm concerned that these fields don't have an expected format.. is this |
||
| expiryYear: text, | ||
| cvc: text | ||
| } | ||
|
|
||
| autofill.Address = { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fields that an address consists of depends on the locale of the website, form, and user agent. How do you plan to deal with this? I'm thinking that Japanese has both romanized and traditional address formats, but also Hindi and others. |
||
| fields: [* autofill.Field] | ||
| } | ||
|
|
||
| </pre> | ||
| </dd> | ||
| <dt>Return Type</dt> | ||
| <dd> | ||
| <code> | ||
| EmptyResult | ||
| </code> | ||
| </dd> | ||
| </dl> | ||
|
|
||
| <div algorithm="remote end steps for autofill.Trigger"> | ||
|
|
||
| The [=remote end steps=] with |session| and |command parameters| are: | ||
|
|
||
| 1. Let |navigable id| be the value of the <code>context</code> field of | ||
| |command parameters|. | ||
|
|
||
| 1. Let |navigable| be the result of [=trying=] to [=get a navigable=] | ||
| with |navigable id|. | ||
|
|
||
| 1. Let |document| be |navigable|'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. 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. Let |card| be the value of the <code>card</code> field of |command parameters| if present, or null otherwise. | ||
|
|
||
| 1. Let |address| be the value of the <code>address</code> field of |command parameters| if present, or null otherwise. | ||
|
|
||
| 1. If, for any reason, the remote end is unable to [=autofill=], return error with | ||
| [=error code=] [=unsupported operation=]. | ||
|
|
||
| 1. If both |card| and |address| are not null, return error with [=error code=] | ||
| [=invalid argument=]. | ||
|
|
||
| 1. If both |card| and |address| are null, return error with [=error code=] | ||
| [=invalid argument=]. | ||
|
|
||
| 1. Let |parsed card| be the result of parsing |card| as an <code>autofill.Card</code>. | ||
|
|
||
| 1. Let |parsed address| be the result of parsing |card| as an <code>autofill.Address</code>. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to humbly propose that we have separate commands that add the mock data, which will make it easier to split out parsing failures from autofill itself not working due to issues in form/field classification or field-filling.
and so on. Another suggestion would be to add events for autofill domain similar to userPromptHandler. This would make it possible to have tests go through the following flow:
|
||
|
|
||
| 1. The [=/user agent=] should [=autofill=] |element| and |element|'s [=form | ||
sadym-chromium marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| owner=], while taking into account the contents of |parsed card| and |parsed address|. | ||
|
|
||
| 1. Return [=success=] with data null. | ||
|
|
||
| </div> | ||
|
|
||
| #### The autofill.FieldName Type #### {#type-autofill-FieldName} | ||
|
|
||
| <pre class="cddl" data-cddl-module="local-cddl"> | ||
| AutofillToken = "name" / | ||
| "honorific-prefix" / | ||
| "given-name" / | ||
| "additional-name" / | ||
| "family-name" / | ||
| "honorific-suffix" / | ||
| "nickname" / | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the intent here to be exhaustive? I feel like one-time-code, nickname, organization-title, bday, impp are not relevant if we are focusing on autofill for shopping cart checkout pages. |
||
| "username" / | ||
| "new-password" / | ||
| "current-password" / | ||
| "one-time-code" / | ||
| "organization-title" / | ||
| "organization" / | ||
| "street-address" / | ||
| "address-line1" / | ||
| "address-line2" / | ||
| "address-line3" / | ||
| "address-level4" / | ||
| "address-level3" / | ||
| "address-level2" / | ||
| "address-level1" / | ||
| "country" / | ||
| "country-name" / | ||
| "postal-code" / | ||
| "cc-name" / | ||
| "cc-given-name" / | ||
| "cc-additional-name" / | ||
| "cc-family-name" / | ||
| "cc-number" / | ||
| "cc-exp" / | ||
| "cc-exp-month" / | ||
| "cc-exp-year" / | ||
| "cc-csc" / | ||
| "cc-type" / | ||
| "transaction-currency" / | ||
| "transaction-amount" / | ||
| "language" / | ||
| "bday" / | ||
| "bday-day" / | ||
| "bday-month" / | ||
| "bday-year" / | ||
| "sex" / | ||
| "url" / | ||
| "photo" / | ||
| "tel" / | ||
| "tel-country-code" / | ||
| "tel-national" / | ||
| "tel-area-code" / | ||
| "tel-local" / | ||
| "tel-local-prefix" / | ||
| "tel-local-suffix" / | ||
| "tel-extension" / | ||
| "email" / | ||
| "impp" | ||
| </pre> | ||
|
|
||
| <pre class="cddl" data-cddl-module="remote-cddl,local-cddl"> | ||
| autofill.FieldName = AutofillToken; | ||
| </pre> | ||
|
|
||
| The <code>autofill.FieldName</code> is an <code>AutofillToken</code>. Valid token | ||
| values are defined in [=autofill detail tokens=]. | ||
|
|
||
| ### Events ### {#module-input-events} | ||
|
|
||
| #### The input.fileDialogOpened Event #### {#event-input-fileDialogOpened} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autofill (consisting of form/field classification, data selection, and filling) all happens for the entire form, not one element. Many of these field tokens are commonly split across multiple form fields, and sometimes across multiple forms. (Also, <input> with no <form>.) So I'm not sure what to say about this parameter except it's unnecessary IMO.