diff options
Diffstat (limited to 'dom/workers/test/serviceworkers/source_message_posting_worker.js')
-rw-r--r-- | dom/workers/test/serviceworkers/source_message_posting_worker.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/dom/workers/test/serviceworkers/source_message_posting_worker.js b/dom/workers/test/serviceworkers/source_message_posting_worker.js new file mode 100644 index 000000000..36ce951fe --- /dev/null +++ b/dom/workers/test/serviceworkers/source_message_posting_worker.js @@ -0,0 +1,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."); + } +}; |