summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/resources/keepalive-redirect-iframe.html
blob: fdee00f312479209375a96467c80a96f91edb6d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!doctype html>
<html>
<meta charset="utf-8">
<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 = SEARCH_PARAMS.get('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>