empty-payload.https.window.js (1359B)
1 // META: script=/common/get-host-info.sub.js 2 // META: script=/common/utils.js 3 // META: script=/fetch/fetch-later/resources/fetch-later-helper.js 4 'use strict'; 5 6 const {HTTPS_ORIGIN, HTTPS_NOTSAMESITE_ORIGIN} = get_host_info(); 7 8 // In a cross-origin iframe, test making a POST request with empty 9 // payload, which is not accepted by fetchLater API. 10 for (const dataType in BeaconDataType) { 11 if (dataType === BeaconDataType.FormData) { 12 // An empty FormData object serializes to non-empty String. Hence, there 13 // will be no error thrown from fetchLater. 14 parallelPromiseTest( 15 async _ => await loadFetchLaterIframe(HTTPS_NOTSAMESITE_ORIGIN, { 16 activateAfter: 0, 17 method: 'POST', 18 bodyType: dataType, 19 bodySize: 0, 20 }), 21 `fetchLater() accepts a non-empty POST request body of ${ 22 dataType} in a default cross-origin iframe.`); 23 continue; 24 } 25 26 parallelPromiseTest( 27 async _ => await loadFetchLaterIframe(HTTPS_NOTSAMESITE_ORIGIN, { 28 activateAfter: 0, 29 method: 'POST', 30 bodyType: dataType, 31 bodySize: 0, 32 expect: new FetchLaterIframeExpectation( 33 FetchLaterExpectationType.ERROR_JS, TypeError), 34 }), 35 `fetchLater() does not accept empty POST request body of ${ 36 dataType} in a default cross-origin iframe.`); 37 }