RESOLVED FIXED 274214
Constructed FormData object should not contain entries for the Image Button submitter by default
https://bugs.webkit.org/show_bug.cgi?id=274214
Summary Constructed FormData object should not contain entries for the Image Button s...
Jon Jensen
Reported 2024-05-15 09:00:44 PDT
Overview: When a `FormData` object is constructed in a submit handler, it automatically contains entries for the Image Button submitter even if the `submitter` parameter is not passed to the constructor. This does not happen with regular (non-image) submitters. This also does not happen in Chromium or Gecko. This is related to https://bugs.webkit.org/show_bug.cgi?id=239070, but was not resolved by https://commits.webkit.org/r293444 Steps to Reproduce: 1. Create a page with the following content: > <script> > function onSubmit(event) { > event.preventDefault(); > const formData = new FormData(event.target); > console.log(new URLSearchParams(formData).toString()); > } > </script> > <form onsubmit="onSubmit(event)"> > <input > name="submitter" > type="image" > name="input" > href="/some/image.png" > alt="Image Button" > /> > </form> ``` 2. Click the `Image Button` Actual Results: Something like `submitter.x=10&submitter.y=4` is logged Expected Results: An empty string should be logged. The submitter should only be included in the FormData object if it is explicitly passed to the constructor. See https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData#submitter
Attachments
testcase (1.19 KB, text/html)
2024-05-15 21:12 PDT, Karl Dubost
no flags
Karl Dubost
Comment 1 2024-05-15 21:12:40 PDT
Created attachment 471419 [details] testcase Adding the testcase
Radar WebKit Bug Importer
Comment 2 2024-05-15 22:13:02 PDT
Ahmad Saleem
Comment 3 2024-05-16 05:44:40 PDT
This is even earlier attempt of bug 239070 which tried to extend WPT test as well for image. https://bugs.webkit.org/show_bug.cgi?id=234069 Also later `image` changes from bug 234069 were not carried into 239070. So it might be just reapplying 234069 (image specific changes)?
Ahmad Saleem
Comment 4 2024-05-16 05:54:12 PDT
(In reply to Ahmad Saleem from comment #3) > This is even earlier attempt of bug 239070 which tried to extend WPT test as > well for image. > > https://bugs.webkit.org/show_bug.cgi?id=234069 > > Also later `image` changes from bug 234069 were not carried into 239070. So > it might be just reapplying 234069 (image specific changes)? Confirmed on local build that just doing `image` specific changes from bug 234069 fixes this test case.
Ahmad Saleem
Comment 5 2024-05-16 06:08:02 PDT
Next steps should be - take tests from bug 234069 and upload them on WPT - so if we introduce this behavior - we don't regress leading to: rdar://88359001 and then once test lands then do this changes and ensure that WPT passes.
Jon Jensen
Comment 6 2024-05-16 08:13:23 PDT
Opened a PR to add wpts around this: https://github.com/web-platform-tests/wpt/pull/46316
Ahmad Saleem
Comment 7 2024-05-16 08:14:49 PDT
(In reply to Jon Jensen from comment #6) > Opened a PR to add wpts around this: > https://github.com/web-platform-tests/wpt/pull/46316 Perfect! Once this get merged, I will add it to WebKit repo and then do PR to fix it and confirm whether it fixes everything and don't regress any behavior.
Ahmad Saleem
Comment 8 2024-05-17 09:21:40 PDT
Draft PR - https://github.com/WebKit/WebKit/pull/28713 ^ I will check bit more locally to confirm it does not cause similar regression as in bug 239070 I synced the tests in bug 274277.
Ahmad Saleem
Comment 9 2024-05-17 09:36:15 PDT
(In reply to Ahmad Saleem from comment #8) > Draft PR - https://github.com/WebKit/WebKit/pull/28713 > > ^ I will check bit more locally to confirm it does not cause similar > regression as in bug 239070 > > I synced the tests in bug 274277. I took tests from: https://github.com/web-platform-tests/wpt/pull/32916 and confirmed that they pass and don't lead to regression as in rdar://88359001. Got following on local: PASS Image submit button should submit the right coordinates on mouse clicks PASS With multiple image submit buttons, the correct one should be used
EWS
Comment 10 2024-05-17 20:36:06 PDT
Committed 278944@main (69eafe9632ca): <https://commits.webkit.org/278944@main> Reviewed commits have been landed. Closing PR #28713 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.