summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/windows/auxiliary-browsing-contexts/resources/close-opener.html
blob: f41773ed2cd00945e844e6ec3abb3c0e49b00854 (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">
<html>
<body onload="closeOpener()">
<p>This window should close its opener.</p>
<script src="/common/PrefixedLocalStorage.js"></script>
<script>
var prefixedLocalStorage = new PrefixedLocalStorageResource({
  close_on_cleanup: true
});
var prefixedLocalStorage = new PrefixedLocalStorageResource({
  close_on_cleanup: true
});
function closeOpener () {
  if (window.opener) {
    window.opener.close();

    // Give the browsing context a chance to dispose of itself
    function waitForContextDiscard () {
      if (window.opener === null) {
        return prefixedLocalStorage.setItem('openerIsNull', 'true');
      }
      return setTimeout(waitForContextDiscard, 0);
    }
    waitForContextDiscard();
  }
}
</script>
</body>
</html>