summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/opener-closed.html
blob: 106c3f97cb231aeadc7a09a22f402ba631fe8882 (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
<!doctype html>
<meta charset="utf-8">
<html>
  <head>
    <title>Auxiliary Browsing Contexts: window.opener when Opener Removed/Closed</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src="/common/PrefixedLocalStorage.js"></script>
  </head>
  <body>
    <div id="log"></div>
    <script>
    var prefixedLocalStorage;
    setup (() => prefixedLocalStorage = new PrefixedLocalStorageTest());
    async_test(t => {
      t.add_cleanup (() => prefixedLocalStorage.cleanup());
      var a       = document.createElement('a');
      a.href      = prefixedLocalStorage.url('resources/open-closer.html');
      a.target    = '_blank';
      prefixedLocalStorage.onSet('openerIsNull', t.step_func_done(e => {
        // The window for this auxiliary browsing context's opener
        // has been closed and discarded, so the aux browsing context
        // should now report `null` for `window.opener`
        assert_equals(e.newValue, 'true');
      }));
      document.body.append(a);
      a.click();
    }, 'An auxiliary browsing context should report `null` for `window.opener` when that browsing context is discarded');
    </script>
  </body>
</html>