summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/resources/keepalive-iframe.html
blob: 47de0da7790618224f70171c12dc8fd04436c0e3 (plain)
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
<!doctype html>
<html>
<meta charset="utf-8">
<script src="/common/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script>
const SEARCH_PARAMS = new URL(location.href).searchParams;
const ORIGIN1 = SEARCH_PARAMS.get('origin1') || '';
const ORIGIN2 = SEARCH_PARAMS.get('origin2') || '';
const WITH_HEADERS = !!SEARCH_PARAMS.has('with-headers');
const TOKEN = token();

const url =
    `${ORIGIN1}/fetch/api/resources/redirect.py?` +
    `delay=500&` +
    `allow_headers=foo&` +
    `location=${ORIGIN2}/fetch/api/resources/stash-put.py?key=${TOKEN}%26value=on`;

addEventListener('load', () => {
  const headers = WITH_HEADERS ? {'foo': 'bar'} : undefined;
  let p = fetch(url, {keepalive: true, headers});
  window.parent.postMessage(TOKEN, '*');
});
</script>
</html>