summaryrefslogtreecommitdiffstats
path: root/dom/broadcastchannel/tests/test_message_after_close.html
blob: a14b590651c71d95cc177d332a7fc74a1f567cd1 (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>
<html>
<head>
  <title>Test for BroadcastChannel - message after close</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>
SimpleTest.waitForExplicitFinish();

let a = new BroadcastChannel('a');
let b = new BroadcastChannel('a');
let count = 0;

a.onmessage = function() {
  ++count;
  a.close();

  setTimeout(() => {
    is(count, 1, "Only 1 message received");
    SimpleTest.finish();
  }, 0);
}

for (let i = 0; i < 100; ++i) {
  b.postMessage(42);
}
</script>
</body>
</html>