summaryrefslogtreecommitdiffstats
path: root/dom/broadcastchannel/tests/broadcastchannel_sharedWorker.js
blob: ad24ce39ea3ef92169d64308eff958feac777f2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* eslint-env worker */

onconnect = function(evt) {
  evt.ports[0].onmessage = function(evt1) {
    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();
    });

    evt1.target.postMessage("READY");
  };
};