Bug 102320

Summary: HTMLFormElement#requestAutocomplete() should require a user action
Product: WebKit Reporter: Elliott Sprehn <esprehn>
Component: FormsAssignee: Dan Beam <dbeam>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, dglazkov, esprehn, estade, fishd, ian, isherman, jamesr, japhet, mifenton, ojan, tkent, tkent+wkapi, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 100560    
Attachments:
Description Flags
Patch
none
changelog typo
none
if specified impl
none
if unspecified impl
none
if specified impl
none
Patch for landing
none
Patch for landing none

Description Elliott Sprehn 2012-11-14 19:50:31 PST
requestAutocomplete should require a user action and should dispatch a failure event when triggered from a non user action:

ex.

setTimeout(function() {
  form.requestAutocomplete(); // this should always fail.
}, 0);
Comment 1 Adam Barth 2012-11-14 21:15:29 PST
Should be an easy patch.
Comment 2 Dan Beam 2012-12-05 17:14:50 PST
If I'm just passing along this info to the embedder (so it can fail if it'd like), I guess I have to wait for the code to land in Chrome before I can test firing an autocompleteerror on a non-user gesture.  Also, is there a way to simulate user gestures in layout tests?
Comment 3 Dan Beam 2012-12-05 17:29:58 PST
Hey Ian and Adam,

This bug is about requiring HTMLFormElement#requestAutocomplete() be based on a user action, else dispatching an error.  Is this behavior going to be specified (meaning all WebKit implementations will need to behave the same) or will it be up to each embedder/browser to choose this behavior?

Whether it's standardized or not affects my patch, that's why I'm asking.
Comment 4 Dan Beam 2012-12-05 17:42:23 PST
Created attachment 177887 [details]
Patch
Comment 5 Elliott Sprehn 2012-12-05 17:44:22 PST
(In reply to comment #3)
> Hey Ian and Adam,
> 
> This bug is about requiring HTMLFormElement#requestAutocomplete() be based on a user action, else dispatching an error.  Is this behavior going to be specified (meaning all WebKit implementations will need to behave the same) or will it be up to each embedder/browser to choose this behavior?
> 
> Whether it's standardized or not affects my patch, that's why I'm asking.

As the person writing the preliminary spec I was going to require it for all implementations.
Comment 6 WebKit Review Bot 2012-12-05 17:45:38 PST
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Comment 7 Dan Beam 2012-12-05 17:48:01 PST
Created attachment 177888 [details]
changelog typo
Comment 8 Dan Beam 2012-12-05 17:55:07 PST
esprehn@: I only see 2 differentiations on whether something is a user action or not in this document (http://dev.w3.org/html5/spec/single-page.html)

1) http://dev.w3.org/html5/spec/single-page.html#history-notes

"""
In addition, a user agent could ignore calls to pushState() that are invoked on a timer, or from event listeners that are not triggered in response to a clear user action, or that are invoked in rapid succession.
"""

2) http://dev.w3.org/html5/spec/single-page.html#context-menus

"""
The context information of the event must be initialized to the same values as the last MouseEvent user interaction event that was fired as part of the gesture that that was interpreted as a request for the context menu.
"""

It'd seem only #1 is applicable, and it's only a recommendation (if that).  However, there's a first time for everything, :).
Comment 9 Dan Beam 2012-12-05 18:04:29 PST
Created attachment 177894 [details]
if specified impl
Comment 10 Kent Tamura 2012-12-05 18:09:40 PST
Comment on attachment 177894 [details]
if specified impl

View in context: https://bugs.webkit.org/attachment.cgi?id=177894&action=review

> Source/WebCore/ChangeLog:11
> +        No new tests (OOPS!).

OOPS!
You had better mention that you updated form-request-autocomplete.html.
Comment 11 Dan Beam 2012-12-05 18:10:35 PST
Comment on attachment 177894 [details]
if specified impl

View in context: https://bugs.webkit.org/attachment.cgi?id=177894&action=review

>> Source/WebCore/ChangeLog:11
>> +        No new tests (OOPS!).
> 
> OOPS!
> You had better mention that you updated form-request-autocomplete.html.

Yeah, I don't know why the scripts aren't picking this up automatically... will update now.
Comment 12 Elliott Sprehn 2012-12-05 18:13:16 PST
(In reply to comment #8)
> esprehn@: I only see 2 differentiations on whether something is a user action or not in this document (http://dev.w3.org/html5/spec/single-page.html)

http://www.whatwg.org/specs/web-apps/current-work/#allowed-to-show-a-pop-up

window.open() is indeed spec'ed to require a trusted event. See also DOMWindow::allowPopUp which has the user gesture code baked into webkit, not into the embedder.
Comment 13 Dan Beam 2012-12-05 18:13:23 PST
Created attachment 177896 [details]
if unspecified impl
Comment 14 Dan Beam 2012-12-05 18:14:36 PST
Created attachment 177898 [details]
if specified impl
Comment 15 Dan Beam 2012-12-05 18:25:00 PST
(In reply to comment #13)
> Created an attachment (id=177896) [details]
> if unspecified impl

I talked with esprehn@ and we agreed that we'd want to spec the safer, simpler to implement version of this API.  So, I've obsoleted the unspecified implementation in favor of the specified one.

tkent@: if I could steal a minute of your time it'd be awesome to get a [very short] review on the non-obsolete patch (https://bugs.webkit.org/attachment.cgi?id=177898&action=review) now that I'm done juggling this bug's attachments, :P.
Comment 16 Kent Tamura 2012-12-05 18:31:26 PST
Comment on attachment 177898 [details]
if specified impl

View in context: https://bugs.webkit.org/attachment.cgi?id=177898&action=review

> Source/WebCore/ChangeLog:14
> +        * fast/forms/form-request-autocomplete.html:
> +        
> +        Added a test to ensure that dispatching a call to HTMLFormElement#requestAutocomplete() in a setTimeout() (which will
> +        never be a user gesture) always fails.

nit: This file is not a part of WebCore. So you don't need to follow the file list style here.
"fast/forms/form-request-autocomplete.html is updated." is enough.
Comment 17 Adam Barth 2012-12-05 18:38:14 PST
> As the person writing the preliminary spec I was going to require it for all implementations.

Makes sense.
Comment 18 Ian 'Hixie' Hickson 2012-12-05 19:36:38 PST
I think it makes sense that it happen that way, but in practice the spec won't require it, since it's UI. But acting as if it does is appropriate.
Comment 19 Dan Beam 2012-12-05 21:32:12 PST
Created attachment 177925 [details]
Patch for landing
Comment 20 Dan Beam 2012-12-05 21:32:55 PST
Comment on attachment 177898 [details]
if specified impl

View in context: https://bugs.webkit.org/attachment.cgi?id=177898&action=review

>> Source/WebCore/ChangeLog:14
>> +        never be a user gesture) always fails.
> 
> nit: This file is not a part of WebCore. So you don't need to follow the file list style here.
> "fast/forms/form-request-autocomplete.html is updated." is enough.

Done.
Comment 21 Kent Tamura 2012-12-05 21:47:53 PST
Comment on attachment 177925 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=177925&action=review

> Source/WebCore/ChangeLog:11
> +        * fast/forms/form-request-autocomplete.html is updated.

"* " is confusing.  It looks like a part of WebCore files.
Comment 22 Dan Beam 2012-12-05 22:08:18 PST
Created attachment 177931 [details]
Patch for landing
Comment 23 WebKit Review Bot 2012-12-05 22:08:57 PST
Comment on attachment 177925 [details]
Patch for landing

Clearing flags on attachment: 177925

Committed r136800: <http://trac.webkit.org/changeset/136800>
Comment 24 WebKit Review Bot 2012-12-05 22:09:03 PST
All reviewed patches have been landed.  Closing bug.
Comment 25 Dan Beam 2012-12-05 22:09:14 PST
Comment on attachment 177925 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=177925&action=review

>> Source/WebCore/ChangeLog:11
>> +        * fast/forms/form-request-autocomplete.html is updated.
> 
> "* " is confusing.  It looks like a part of WebCore files.

Sorry, removed.
Comment 26 Kent Tamura 2012-12-05 22:09:47 PST
Comment on attachment 177931 [details]
Patch for landing

OMG
Comment 27 Dan Beam 2012-12-05 22:11:03 PST
(In reply to comment #24)
> All reviewed patches have been landed.  Closing bug.

Whoops, too late.  I'll remember next time.  I understand now, looking at the patchset (http://trac.webkit.org/changeset/136800), why * matters.
Comment 28 Dan Beam 2012-12-05 22:14:15 PST
(In reply to comment #26)
> (From update of attachment 177931 [details])
> OMG

Yes, bad timing :(.  Is there anything else I need to do for this bug?
Comment 29 Dan Beam 2012-12-05 22:18:26 PST
Comment on attachment 177925 [details]
Patch for landing

this was the committed patch