summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/source_message_posting_worker.js
blob: 8ca6246c51b73fcfeb35b5ff721b4959ef851687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
onmessage = function (e) {
  if (!e.source) {
    dump("ERROR: message doesn't have a source.");
  }

  if (!(e instanceof ExtendableMessageEvent)) {
    e.source.postMessage("ERROR. event is not an extendable message event.");
  }

  // The client should be a window client
  if (e.source instanceof WindowClient) {
    e.source.postMessage(e.data);
  } else {
    e.source.postMessage("ERROR. source is not a window client.");
  }
};