New issue
Advanced search Search tips

Issue 646790 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Chrome submits a submit button value even for form.submit()

Reported by fanto...@gmail.com, Sep 14 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0

Steps to reproduce the problem:
Issue https://bugs.chromium.org/p/chromium/issues/detail?id=378949 reproduces again on: 
Google Chrome 54.0.2840.16 beta-m (64-bit)
Google Chrome 54.0.2840.8 dev-m (64-bit)
Google Chrome Version 55.0.2860.0 canary (64-bit)

What is the expected behavior?

What went wrong?
See https://bugs.chromium.org/p/chromium/issues/detail?id=378949

Did this work before? Yes 53.0.2785.113 m

Chrome version:  55.0.2860.0 canary (64-bit)out:version'>  Channel: canary
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
 
Components: -Blink Blink>Forms
Owner: tkent@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 2 by tkent@chromium.org, Sep 15 2016

Components: -Blink>Forms Blink>Forms>Submission
Labels: -Type-Bug M-54 OS-Android OS-Chrome OS-Linux OS-Mac Type-Bug-Regression
Status: Started (was: Assigned)

Comment 3 by tkent@chromium.org, Sep 15 2016

minimum repro:

<form onsubmit="this.submit(); return false;">
 <input name="t" value="text">
 <input type=submit name="b" value="Next">
</form>

1. Press [Next] Button
2. Observe the new URL

Expected: ...?t=text
Actual: ...?t=text&b=Next

Comment 4 by tkent@chromium.org, Sep 15 2016

Summary: Chrome submits a submit button value even for form.submit() (was: chrome submits double value when using jquery validate)
Project Member

Comment 5 by bugdroid1@chromium.org, Sep 16 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/864df709bb6b675152537a276723c2d0a8757e48

commit 864df709bb6b675152537a276723c2d0a8757e48
Author: tkent <tkent@chromium.org>
Date: Fri Sep 16 01:39:31 2016

submit() in submit event handler should not contains a value of a submit button.

The value of a submit button is appended to a FormData if its activatedSubmit flag
is set.
In a case of form.submit() is called in submit event handler, we did:

1. Set activatedSubmit flag of the submit button
2. Dispatch submit event
2.1. form.submit() builds FormData
3. Build FormData if the submit event was not prevented
4. Clear activatedSubmit flag of the submit button

In step 2.1, we should not include the submit button. So, this CL changes the
process as follows:

1. Dispatch submit event
1.1 form.submit() builds FormData
2. If the submit event was not prevented,
2.1. Set activatedSubmit flag of the submit button
2.2. Build FormData
2.3. Clear activatedSubmit flag of the submit button

Implementation:
We called setActivatedSubmit() before/after prepareForSubmission(). Instead, we
pass a submit button element to prepareForSubmission(), and call
setActivatedSubmit() just before/after building FormData.

BUG= 646790 

Review-Url: https://codereview.chromium.org/2340213002
Cr-Commit-Position: refs/heads/master@{#419073}

[add] https://crrev.com/864df709bb6b675152537a276723c2d0a8757e48/third_party/WebKit/LayoutTests/fast/forms/form-submit-in-submit-event.html
[modify] https://crrev.com/864df709bb6b675152537a276723c2d0a8757e48/third_party/WebKit/Source/core/html/HTMLButtonElement.cpp
[modify] https://crrev.com/864df709bb6b675152537a276723c2d0a8757e48/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
[modify] https://crrev.com/864df709bb6b675152537a276723c2d0a8757e48/third_party/WebKit/Source/core/html/HTMLFormElement.h
[modify] https://crrev.com/864df709bb6b675152537a276723c2d0a8757e48/third_party/WebKit/Source/core/html/forms/ImageInputType.cpp
[modify] https://crrev.com/864df709bb6b675152537a276723c2d0a8757e48/third_party/WebKit/Source/core/html/forms/SubmitInputType.cpp
[modify] https://crrev.com/864df709bb6b675152537a276723c2d0a8757e48/third_party/WebKit/Source/core/loader/FormSubmission.cpp
[modify] https://crrev.com/864df709bb6b675152537a276723c2d0a8757e48/third_party/WebKit/Source/core/loader/FormSubmission.h

Comment 6 by tkent@chromium.org, Sep 16 2016

Labels: Merge-Request-54
Status: Fixed (was: Started)

Comment 7 by dimu@chromium.org, Sep 16 2016

Labels: -Merge-Request-54 Merge-Approved-54 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M54 (branch: 2840)

Comment 8 Deleted

Project Member

Comment 9 by bugdroid1@chromium.org, Sep 16 2016

Labels: -merge-approved-54 merge-merged-2840
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f8be4fbd37d679e362c0eac49098fa913dc51ef3

commit f8be4fbd37d679e362c0eac49098fa913dc51ef3
Author: Kent Tamura <tkent@chromium.org>
Date: Fri Sep 16 11:52:08 2016

Merge "submit() in submit event handler should not contains a value of a submit button." to M54 branch

The value of a submit button is appended to a FormData if its activatedSubmit flag
is set.
In a case of form.submit() is called in submit event handler, we did:

1. Set activatedSubmit flag of the submit button
2. Dispatch submit event
2.1. form.submit() builds FormData
3. Build FormData if the submit event was not prevented
4. Clear activatedSubmit flag of the submit button

In step 2.1, we should not include the submit button. So, this CL changes the
process as follows:

1. Dispatch submit event
1.1 form.submit() builds FormData
2. If the submit event was not prevented,
2.1. Set activatedSubmit flag of the submit button
2.2. Build FormData
2.3. Clear activatedSubmit flag of the submit button

Implementation:
We called setActivatedSubmit() before/after prepareForSubmission(). Instead, we
pass a submit button element to prepareForSubmission(), and call
setActivatedSubmit() just before/after building FormData.

BUG= 646790 

Review-Url: https://codereview.chromium.org/2340213002
Cr-Commit-Position: refs/heads/master@{#419073}
(cherry picked from commit 864df709bb6b675152537a276723c2d0a8757e48)

Review URL: https://codereview.chromium.org/2342153003 .

Cr-Commit-Position: refs/branch-heads/2840@{#388}
Cr-Branched-From: 1ae106dbab4bddd85132d5b75c670794311f4c57-refs/heads/master@{#414607}

[add] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/LayoutTests/fast/forms/form-submit-in-submit-event.html
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/HTMLButtonElement.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/HTMLFormElement.h
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/forms/ImageInputType.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/forms/SubmitInputType.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/loader/FormSubmission.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/loader/FormSubmission.h

Cc: nyerramilli@chromium.org
Labels: TE-Verified-54.0.2840.34 TE-Verified-M54
Tested the issue on Win10, Mac OS X 10.11.6, Ubuntu 14.04 using Chrome Beta 54.0.2840.34.

Followed the steps mentioned in c#3, it is working as expected. Adding TE-Verified labels.
Attached screencast for reference.

<form onsubmit="this.submit(); return false;">
 <input name="t" value="text">
 <input type=submit name="b" value="Next">
</form>

1. Press [Next] Button
2. Observe the new URL  

Actual: ...?t=text

646790_Mac.mov
4.6 MB Download
Project Member

Comment 11 by bugdroid1@chromium.org, Oct 27 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f8be4fbd37d679e362c0eac49098fa913dc51ef3

commit f8be4fbd37d679e362c0eac49098fa913dc51ef3
Author: Kent Tamura <tkent@chromium.org>
Date: Fri Sep 16 11:52:08 2016

Merge "submit() in submit event handler should not contains a value of a submit button." to M54 branch

The value of a submit button is appended to a FormData if its activatedSubmit flag
is set.
In a case of form.submit() is called in submit event handler, we did:

1. Set activatedSubmit flag of the submit button
2. Dispatch submit event
2.1. form.submit() builds FormData
3. Build FormData if the submit event was not prevented
4. Clear activatedSubmit flag of the submit button

In step 2.1, we should not include the submit button. So, this CL changes the
process as follows:

1. Dispatch submit event
1.1 form.submit() builds FormData
2. If the submit event was not prevented,
2.1. Set activatedSubmit flag of the submit button
2.2. Build FormData
2.3. Clear activatedSubmit flag of the submit button

Implementation:
We called setActivatedSubmit() before/after prepareForSubmission(). Instead, we
pass a submit button element to prepareForSubmission(), and call
setActivatedSubmit() just before/after building FormData.

BUG= 646790 

Review-Url: https://codereview.chromium.org/2340213002
Cr-Commit-Position: refs/heads/master@{#419073}
(cherry picked from commit 864df709bb6b675152537a276723c2d0a8757e48)

Review URL: https://codereview.chromium.org/2342153003 .

Cr-Commit-Position: refs/branch-heads/2840@{#388}
Cr-Branched-From: 1ae106dbab4bddd85132d5b75c670794311f4c57-refs/heads/master@{#414607}

[add] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/LayoutTests/fast/forms/form-submit-in-submit-event.html
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/HTMLButtonElement.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/HTMLFormElement.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/HTMLFormElement.h
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/forms/ImageInputType.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/html/forms/SubmitInputType.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/loader/FormSubmission.cpp
[modify] https://crrev.com/f8be4fbd37d679e362c0eac49098fa913dc51ef3/third_party/WebKit/Source/core/loader/FormSubmission.h

Sign in to add a comment