summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/resources/header-referrer-inner.html
blob: 2940dbac8e8a9015ae3cb62b72f673494cbfbcb7 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="utils.js"></script>
<title>Fenced frame content to report the value of header.referrer</title>

<body>
<script>
async function init() { // Needed in order to use top-level await.
  // This file is meant to run in a <fencedframe>. It reports back to the
  // outermost page the value of `referer` in the request header:
  //   1.) Nested iframes inside a fenced frame
  //   2.) Nested fenced frames
  //   3.) Top-level fenced frames (aka this frame) after initial navigation
  const [referrer_key, referrer_ack_key] = parseKeylist();

  const referrer_url = generateURL("check-header-referrer.py",
      [referrer_key, referrer_ack_key]);

  const iframe = document.createElement('iframe');
  iframe.src = referrer_url;
  document.body.append(iframe);

  // Wait for ACK, so we know that the outer page has read the last value from
  // the `referrer_key` stash that the iframe above wrote to, and we can write
  // to it again.
  await nextValueFromServer(referrer_ack_key);

  attachFencedFrame(referrer_url);

  // Wait for ACK, so we know that the outer page has read the last value from
  // the `referrer_key` stash that the nested fenced frame wrote to, and we can
  // can write to it again.
  await nextValueFromServer(referrer_ack_key);

  location.href = referrer_url;
}

init();
</script>
</body>