summaryrefslogtreecommitdiffstats
path: root/dom/broadcastchannel/tests/broadcastchannel_worker.js
blob: 4714d59d0216f95726ccb3d84f072467f6426fc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
onmessage = function(evt) {
  if (evt.data != 0) {
    var worker = new Worker("broadcastchannel_worker.js");
    worker.onmessage = function(evt) {
      postMessage(evt.data);
    }
    worker.postMessage(evt.data - 1);
    return;
  }

  var bc = new BroadcastChannel('foobar');
  bc.addEventListener('message', function(event) {
    bc.postMessage(event.data == "hello world from the window" ? "hello world from the worker" : "KO");
    bc.close();
  }, false);

  postMessage("READY");
}