Bug 225238 - Can't decode empty formdata with fetch
Summary: Can't decode empty formdata with fetch
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 14
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-30 11:07 PDT by Jimmy Wärting
Modified: 2022-08-02 12:51 PDT (History)
11 users (show)

See Also:


Attachments
Patch (6.34 KB, patch)
2021-05-03 13:32 PDT, Alex Christensen
youennf: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jimmy Wärting 2021-04-30 11:07:00 PDT
Safari TP Version: 14.2
OS Version: OS X 10.15.7

     Safari: FAIL
    Firefox: OK
    IE/Edge: FAIL

What steps will reproduce the problem?
1. new Response(new FormData()).formData()

What is the expected result?
Get back a empty formdata... It can work if you append at least one item into the FormData.

What happens instead of that?
TypeError: Type error

https://github.com/web-platform-tests/wpt/issues/28607


(plz, switch to github issues instead of using bugzilla)
Comment 1 Alex Christensen 2021-05-03 13:32:36 PDT
Created attachment 427594 [details]
Patch
Comment 2 EWS Watchlist 2021-05-03 13:33:27 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 3 Alex Christensen 2021-05-03 13:35:20 PDT
@Jimmy, I added two of these lines to your test to verify it returns a FormData that is indeed empty:
for (const pair of fd.entries()) { assert_true(false); }
You may consider this in your upstream PR.
Also, I removed an extra one space indent that crept into all but one line of your test.
Comment 4 youenn fablet 2021-05-03 23:07:19 PDT
Comment on attachment 427594 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=427594&action=review

> LayoutTests/imported/w3c/web-platform-tests/fetch/api/body/formdata.any.js:5
> +  for (const pair of fd.entries()) { assert_true(false); }

assert_unreached would be clearer.

> LayoutTests/imported/w3c/web-platform-tests/fetch/api/body/formdata.any.js:15
> +  for (const pair of fd.entries()) { assert_true(false); }

Ditto here.
Comment 5 Radar WebKit Bug Importer 2021-05-07 11:07:37 PDT
<rdar://problem/77663677>
Comment 6 Ahmad Saleem 2022-08-01 12:57:17 PDT
I think this didn't landed yet despite r+ because Safari still fail these tests (matched from within patch to WPT):

https://wpt.fyi/results/fetch/api/body?label=master&label=experimental&aligned&view=subtest&q=formdata

Please ignore my comment, if I am wrong. Thanks!
Comment 7 Alex Christensen 2022-08-02 11:47:32 PDT
Pull request: https://github.com/WebKit/WebKit/pull/2956
Comment 8 EWS 2022-08-02 12:51:43 PDT
Committed 253047@main (0cd625839811): <https://commits.webkit.org/253047@main>

Reviewed commits have been landed. Closing PR #2956 and removing active labels.