summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/referrer-policy/generic/inheritance/popup-inheritance-form-submission.html
blob: 2c03792a0776f5e1fe3447d8fbb4dd8145743016 (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
<!doctype html>
<meta charset="utf-8">
<title>Referrer Policy: popup src="about:blank"</title>
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1370425">
<link rel="help" href="https://html.spec.whatwg.org/#creating-a-new-browsing-context">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>

<iframe src="resources/submit-form-and-remove-frame.html"></iframe>
<script>
async_test(t => {
  // Called by the child frame once it has submitted its form that creates a new
  // `about:blank` window in our browsing context group (therefore, the window
  // is reachable by us).
  window.removeIframe = t.step_func(() => {
    const iframe = document.querySelector('iframe');
    const expected_referrer = iframe.contentWindow.location.href;
    iframe.remove();

    // The child frame is removed, but its form submission navigation is still
    // queued on the opened window's global. Wait until it is run and then
    // evaluate script.
    t.step_timeout(t.step_func_done(() => {
      const window_opened_from_form = window.open("", "does-not-exist");
      assert_equals(document.referrer, expected_referrer);
    }));
  });
}, "A new frame's document.referrer is correct even if its initiator frame is gone");
</script>