1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25

content / test / data / fetch-keepalive.html [blame]

<!doctype html>
<!--
  This page loads the given number of fetch keepalive requests, and then waits for their responses.
-->
<title>Fetching</title>
<script>
const PARAMS = new URL(location.href).searchParams;
const NUM_REQUESTS= PARAMS.has('requests') ? Number(PARAMS.get('requests')) : 1;
const METHOD = PARAMS.get('method') || 'GET';

const promises = [];
for (let i = 0; i < NUM_REQUESTS; i += 1) {
  promises.push(fetch('/beacon', {
    keepalive: true,
    cache: 'no-store',
    method: METHOD
  }));
}
document.title = 'Waiting';
Promise.all(promises).then(() => {
  document.title = 'Resolved';
}, () => {
  document.title = 'Rejected';
});
</script>