summaryrefslogtreecommitdiffstats
path: root/dom/broadcastchannel/tests/broadcastchannel_sharedWorker.js
blob: 17fb8063712d58537b5ec5505b599b6c8080c1e0 (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");
  };
};