summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/serviceworkers/source_message_posting_worker.js
blob: 36ce951fec8d9b1a35a6ff4edb223dbf5e19c09f (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.");
  }
};