Last Comment Bug 607328 - Submitting partially downloaded forms with Enter may be a bad idea
: Submitting partially downloaded forms with Enter may be a bad idea
Status: RESOLVED WONTFIX
:
Product: Core
Classification: Components
Component: HTML: Form Submission (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
: Andrew Overholt [:overholt]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-10-26 08:54 PDT by Ed Avis
Modified: 2011-02-08 03:25 PST (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Ed Avis 2010-10-26 08:54:43 PDT
User-Agent:       Mozilla/5.0 (Windows NT 5.1; rv:2.0b6) Gecko/20100101 Firefox/4.0b6
Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:2.0b6) Gecko/20100101 Firefox/4.0b6

(I encountered this bug in Firefox, but submitted it under the General category since it relates to 'handling of web content'.)

Firefox lets you submit an HTML form by putting focus on it (for example, putting the cursor in a textfield) and pressing Enter.  This works even if the HTML code for the form is only partially downloaded, and even if no submit button has been downloaded yet.  That can lead to surprising results when a user presses Enter and submits a form missing some elements.  Typically, they will get an error page from the server, when it would have been more helpful to wait for the entire form to download before allowing submission.

Reproducible: Always

Steps to Reproduce:
1. Create a web page with the following content, with a pause at the point indicated.  (I used a simple CGI script.)

<html>
<body>
<form method="get" action="/cgi-bin/test_page" enctype="multipart/form-data">
<input type="text" name="y" value="y" />
<!-- Here print the output so far and pause for 10 seconds. -->
<input type="text" name="z" value="z" />
<input type="submit" name=".submit" />
</form>
</body>
</html>

2. Open this page in Firefox.  The first textfield 'y' is displayed.

3. Before the rest of the page is shown, click in the 'y' textfield and press Enter.
Actual Results:  
The form is submitted with parameters 'y=y'.

Expected Results:  
The entire form should have been downloaded first, and then submitted with all the form parameters, in other words 'y=y&z=z'.

Alternatively, the Enter keypress could be ignored if typed before the whole form has been shown.

Arguably, it's not the end of the form that should be waited for, but the Submit button.  If the website has included a Submit button in the HTML printed so far, that's an indication that the user is expected to press it.  So an equivalent action on hitting the Enter key would be fine.

I couldn't find any explicit rule in the HTML 4.01 specification about whether the user agent should wait to see the whole form before submitting.  Looking at the behaviour of other browsers, IE and Chrome share Firefox's behaviour of sending an incomplete form.  Safari appears to avoid the problem by not displaying a partially downloaded <form> element at all.  Nonetheless, I believe that a better user experience and more useful behaviour is to wait for the whole form or a submit button before allowing submission.
Comment 1 Boris Zbarsky [:bz] (still a bit busy) 2010-10-26 09:30:15 PDT
> If the website has included a Submit button in the HTML printed so far

What if it hasn't included such a button at all?
Comment 2 Ed Avis 2010-10-28 03:29:41 PDT
>What if it hasn't included such a button at all?

In that case, I would suggest, wait for the closing </form> before considering the form ready to submit.
Comment 3 Boris Zbarsky [:bz] (still a bit busy) 2010-10-28 06:35:17 PDT
That might not be present either.  And in particular, in HTML5 elements can explicitly declare which form they belong to, so an element for a given form can appear anywhere in the document: before the form, inside the form, after the form, whatever.
Comment 4 Ed Avis 2010-11-09 03:41:27 PST
>And in particular, in HTML5 elements can
>explicitly declare which form they belong to, so an element for a given form
>can appear anywhere in the document

Right.  So if no submit button is seen, wait for the whole document to download
before allowing form submission.

That doesn't change the essential point here, which is that it is unhelpful to
submit a form when even the submit button has not been seen yet, let alone the
rest of the document.  To do so is effectively doing a partial form submission,
which doesn't appear to be what the standards intend and unlikely to be what
the user wants.
Comment 5 Boris Zbarsky [:bz] (still a bit busy) 2010-11-09 08:48:08 PST
That doesn't seem reasonable, since in practice many documents on the web never finish downloading (e.g. because the JS code writes them out and never calls document.close()).

I strongly suggest taking this up in public-html@w3.org.  I agree that there's a problem here; it's just not clear to me how to fix it without breaking some existing sites.
Comment 6 Ed Avis 2010-11-19 03:30:41 PST
Submitted to the W3C bug tracker:
<http://www.w3.org/Bugs/Public/show_bug.cgi?id=11347>
Comment 7 Ed Avis 2011-01-04 04:12:52 PST
The people from the HTML WG have clarified this.  Apparently, the semantics for a partially downloaded form follow the same rules as any partial document: just treat it as if it were the complete page.  This implies that a partially downloaded form can be submitted just as well as a finished one, meaning that Firefox's current behaviour complies with the standard (and
Comment 8 Ed Avis 2011-01-04 04:14:26 PST
Sorry, submitted the form with incomplete content, ironically enough...

The people from the HTML WG have clarified this.  Apparently, the semantics for a partially downloaded form follow the same rules as any partial document: just treat it as if it were the complete page.  This implies that a partially downloaded form can be submitted just as well as a finished one, meaning that Firefox's current behaviour complies with the standard (and incidentally Safari, which stops the user from submitting an incomplete form, is non-compliant).

In my personal view the behaviour is unhelpful to the user and it would be much friendlier to wait for the whole form to be downloaded before trying to submit it, but I am not a standards body.
Comment 9 Mounir Lamouri (:mounir) 2011-01-04 05:46:03 PST
Marking WONTFIX to follow W3C decision. Feel free to reopen if anything new happen.

FTR, I agree with Hixie and I don't think it is useful to check that the page is completely downloaded before allowing form submission. Even more because you can have pages which are constantly updated.
Comment 10 Ed Avis 2011-02-08 03:25:02 PST
>Marking WONTFIX to follow W3C decision.

The final word from the W3C bug linked to is "it is up to the browser".  So if Firefox wished to implement some more user-friendly behaviour here, it would not be against the standard to do so.

Note You need to log in before you can comment on or make changes to this bug.