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
Created attachment 471419 [details] testcase Adding the testcase
<rdar://problem/128176811>
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)?
(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.
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.
Opened a PR to add wpts around this: https://github.com/web-platform-tests/wpt/pull/46316
(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.
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.
(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
Committed 278944@main (69eafe9632ca): <https://commits.webkit.org/278944@main> Reviewed commits have been landed. Closing PR #28713 and removing active labels.