send-multiple-with-activate-after.https.window.js (1125B)
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 {method: 'GET', activateAfter: 10000}); // 10s 21 fetchLater(url + "&method=POST&i=" + i, 22 {method: 'POST', activateAfter: 8000}); // 8s 23 } 24 `); 25 // Delete the iframe to trigger deferred request sending. 26 document.body.removeChild(iframe); 27 28 // The iframe should have sent all requests. 29 await expectBeacon(uuid, {count: total}); 30 }, 'A discarded document sends all its fetchLater requests, no matter how much their activateAfter timeout remain.');