RESOLVED INVALID 19724
Submitting a form with no text input fields doesn't trigger dispatchWillSubmitForm
https://bugs.webkit.org/show_bug.cgi?id=19724
Summary Submitting a form with no text input fields doesn't trigger dispatchWillSubmi...
Tim S
Reported 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.
Attachments
Alexey Proskuryakov
Comment 1 2008-06-25 03:30:59 PDT
Would it be possible for you to create a test application for this problem?
David Kilzer (:ddkilzer)
Comment 2 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?
Deepak Mittal
Comment 3 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
Anne van Kesteren
Comment 4 2023-08-31 06:58:40 PDT
Closing due to lack of follow-up and test.
Note You need to log in before you can comment on or make changes to this bug.