Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}
15 changes: 3 additions & 12 deletions fetch/fetch-later/quota/empty-payload.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}
Loading