From e7fe72b82971e78733c6c71fadc540e2eea47128 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Tue, 24 Mar 2026 20:53:05 +0000 Subject: [PATCH] script: Remove check for zero request body length in `FetchLater` Per the spec discussion in [1] we should only check for a length of `null` and not zero. [1]: https://github.com/whatwg/fetch/pull/1902 Signed-off-by: Tim van der Lippe --- .../empty-payload.https.window.js | 19 +------------------ .../quota/empty-payload.https.window.js | 15 +++------------ .../empty-payload.https.window.js | 19 +------------------ 3 files changed, 5 insertions(+), 48 deletions(-) diff --git a/fetch/fetch-later/quota/cross-origin-iframe/empty-payload.https.window.js b/fetch/fetch-later/quota/cross-origin-iframe/empty-payload.https.window.js index 6c7becfacaf450..c360eb5d2f2a96 100644 --- a/fetch/fetch-later/quota/cross-origin-iframe/empty-payload.https.window.js +++ b/fetch/fetch-later/quota/cross-origin-iframe/empty-payload.https.window.js @@ -8,30 +8,13 @@ const {HTTPS_ORIGIN, HTTPS_NOTSAMESITE_ORIGIN} = get_host_info(); // In a cross-origin iframe, test making a POST request with empty // payload, which is not accepted by fetchLater API. for (const dataType in BeaconDataType) { - if (dataType === BeaconDataType.FormData) { - // An empty FormData object serializes to non-empty String. Hence, there - // will be no error thrown from fetchLater. - parallelPromiseTest( - async _ => await loadFetchLaterIframe(HTTPS_NOTSAMESITE_ORIGIN, { - activateAfter: 0, - method: 'POST', - bodyType: dataType, - bodySize: 0, - }), - `fetchLater() accepts a non-empty POST request body of ${ - dataType} in a default cross-origin iframe.`); - continue; - } - parallelPromiseTest( async _ => await loadFetchLaterIframe(HTTPS_NOTSAMESITE_ORIGIN, { activateAfter: 0, method: 'POST', bodyType: dataType, bodySize: 0, - expect: new FetchLaterIframeExpectation( - FetchLaterExpectationType.ERROR_JS, TypeError), }), - `fetchLater() does not accept empty POST request body of ${ + `fetchLater() accepts an empty POST request body of ${ dataType} in a default cross-origin iframe.`); } diff --git a/fetch/fetch-later/quota/empty-payload.https.window.js b/fetch/fetch-later/quota/empty-payload.https.window.js index c2c4dd50326c0a..7b23e4dc3902de 100644 --- a/fetch/fetch-later/quota/empty-payload.https.window.js +++ b/fetch/fetch-later/quota/empty-payload.https.window.js @@ -14,18 +14,9 @@ for (const dataType in BeaconDataType) { body: makeBeaconData('', dataType) }; - if (dataType === BeaconDataType.FormData) { - // An empty FormData object serializes to non-empty String. Hence, there - // will be no error thrown from fetchLater. - parallelPromiseTest(async _ => { - expectFetchLater(requestInit); - }, `fetchLater() accepts a non-empty POST request body of ${dataType}.`); - continue; - } - test( - () => assert_throws_js(TypeError, () => fetchLater('/', requestInit)), - `fetchLater() does not accept an empty POST request body of ${ - dataType}.`); + parallelPromiseTest(async _ => { + expectFetchLater(requestInit); + }, `fetchLater() accepts an empty POST request body of ${dataType}.`); } // Test making HTTP non-POST requests, which has no payload and should be diff --git a/fetch/fetch-later/quota/same-origin-iframe/empty-payload.https.window.js b/fetch/fetch-later/quota/same-origin-iframe/empty-payload.https.window.js index 53cae60047eaef..b327fc88efe364 100644 --- a/fetch/fetch-later/quota/same-origin-iframe/empty-payload.https.window.js +++ b/fetch/fetch-later/quota/same-origin-iframe/empty-payload.https.window.js @@ -8,30 +8,13 @@ const {HTTPS_ORIGIN, HTTPS_NOTSAMESITE_ORIGIN} = get_host_info(); // In a same-origin iframe, test making a POST request with empty payload, // which is not accepted by fetchLater API. for (const dataType in BeaconDataType) { - if (dataType === BeaconDataType.FormData) { - // An empty FormData object serializes to non-empty String. Hence, there - // will be no error thrown from fetchLater. - parallelPromiseTest( - async _ => await loadFetchLaterIframe(HTTPS_ORIGIN, { - activateAfter: 0, - method: 'POST', - bodyType: dataType, - bodySize: 0, - }), - `fetchLater() accepts a non-empty POST request body of ${ - dataType} in same-origin iframe.`); - continue; - } - parallelPromiseTest( async _ => await loadFetchLaterIframe(HTTPS_ORIGIN, { activateAfter: 0, method: 'POST', bodyType: dataType, bodySize: 0, - expect: new FetchLaterIframeExpectation( - FetchLaterExpectationType.ERROR_JS, TypeError), }), - `fetchLater() does not accept empty POST request body of ${ + `fetchLater() accepts an empty POST request body of ${ dataType} in same-origin iframe.`); }