send-multiple.https.window.js (978B)
1 // META: script=/common/utils.js 2 // META: script=/fetch/fetch-later/resources/fetch-later-helper.js 3 // META: timeout=long 4 5 'use strict'; 6 7 parallelPromiseTest(async t => { 8 const uuid = token(); 9 const url = generateSetBeaconURL(uuid); 10 const numPerMethod = 20; 11 const total = numPerMethod * 2; 12 13 // Loads an iframe that creates `numPerMethod` GET & POST fetchLater requests. 14 const iframe = await loadScriptAsIframe(` 15 const url = '${url}'; 16 for (let i = 0; i < ${numPerMethod}; i++) { 17 // Changing the URL of each request to avoid HTTP Cache issue. 18 // See crbug.com/1498203#c17. 19 fetchLater(url + "&method=GET&i=" + i); 20 fetchLater(url + "&method=POST&i=" + i, {method: 'POST'}); 21 } 22 `); 23 // Delete the iframe to trigger deferred request sending. 24 document.body.removeChild(iframe); 25 26 // The iframe should have sent all requests. 27 await expectBeacon(uuid, {count: total}); 28 }, 'A discarded document sends all its fetchLater requests.');