summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/test/browser/sharedWorker.js
blob: 01188ed10a2ce12ebd0703424db491bef73c04d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
let ports = 0;
self.onconnect = e => {
  ++ports;
  e.ports[0].onmessage = event => {
    if (event.data === "count") {
      e.ports[0].postMessage(ports);
      return;
    }

    if (event.data === "close") {
      self.close();
      return;
    }

    // Error.
    e.ports[0].postMessage(-1);
  };
};