summaryrefslogtreecommitdiffstats
path: root/dom/html/test/test_window_open_from_closing.html
blob: 0d38c88d84a9ac5696f831ea0ad40d0d678c2a90 (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
41
42
43
<!DOCTYPE html>
<html>
<head>
  <title>window.open from a window being closed</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
  <h1>window.open from a window being closed</h1>
<script>
add_task(async function() {
  const RELS = ["", "#noopener", "#opener"];
  const FEATURES = [
    "",
    "noopener",
    "width=300",
    "width=300,noopener",
  ];

  let resolver;
  let channel = new BroadcastChannel("test");
  channel.onmessage = function(e) {
    info("message from broadcastchannel: " + e.data);
    if (e.data == "load") {
      resolver();
    }
  };

  for (let rel of RELS) {
    for (let feature of FEATURES) {
      info(`running test: rel=${rel}, feature=${feature}`);

      let loadPromise = new Promise(r => { resolver = r; });
      window.open("file_window_close_and_open.html" + rel, "_blank", feature);
      await loadPromise;
      ok(true, "popup opened successfully - closing...");
      channel.postMessage("close");
    }
  }
});
</script>
</body>
</html>