Bug 19724 - Submitting a form with no text input fields doesn't trigger dispatchWillSubmitForm
Summary: Submitting a form with no text input fields doesn't trigger dispatchWillSubmi...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: PC All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-23 07:23 PDT by Tim S
Modified: 2023-08-31 06:58 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim S 2008-06-23 07:23:28 PDT
Throughout FrameLoader::post and some flavors of FrameLoader::load, there is code like the following

  RefPtr<FormState> formState;
   if (form && !formValues.isEmpty())
       formState = FormState::create(form, formValues, m_frame);

The formState variable is checked later on (if not null) to decide whether or not to call dispatchWillSubmitForm on its client. In general, this means when a post/load originates from HTMLFormElement.submit(), dispatchWillSubmitForm will get triggered. 

This is not the case when the form element in question has no input fields, which happens on many pages that submit blank forms onload for navigation purposes. The post occurs (and navigation can take place as a result), but since the form was "empty", the FrameLoader never sets its m_formAboutToBeSubmitted variable, implying a FormState is never created and the client is left unaware that the navigation was due to a form submit.  

I think the FrameLoader should have a setFormAboutToBeSubmitted method that sets this member after HTMLFormElement::submit(), so that this callback will get fired (and have the empty but non-null form* passed in). Currently, the member is only set in a method called recordFormValue which is called for each text input field on the form.

There is some other code that uses a similar check though and I'm not positive of the side-effects. 
(e.g, some one FrameLoader::load does
...
 bool isFormSubmission = formState
...
and uses isFormSubmission to decide whether or not to do scroll-to-anchor processing. 

So perhaps my proposed sol'n isn't the best way to go and dispatchWillSubmitForm should just be manually invoked with a NULL form* in this case, leaving the rest of the code intact.

Bug 17598 is related, since fixing the issue discussed here would at least let clients use "if(form submit && userGesture()==false)" to get a hint at otherwise uncaught client redirects.
Comment 1 Alexey Proskuryakov 2008-06-25 03:30:59 PDT
Would it be possible for you to create a test application for this problem?
Comment 2 David Kilzer (:ddkilzer) 2010-01-04 16:42:27 PST
Tim, form submission code has changed a lot since this bug was filed.  Does it still reproduce?  Can you provide a test application that reproduces the issue per Comment #1?
Comment 3 Deepak Mittal 2014-02-02 20:44:31 PST
Hi Tim S,

In the latest code FrameLoader::post is not present and I am not able to find the code 
if (form && !formValues.isEmpty())
       formState = FormState::create(form, formValues, m_frame);

so please verify your issue on the latest code and if it is not happening then you can close this issue..

Thanks
Comment 4 Anne van Kesteren 2023-08-31 06:58:40 PDT
Closing due to lack of follow-up and test.