summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/source_message_posting_worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/serviceworkers/test/source_message_posting_worker.js')
-rw-r--r--dom/serviceworkers/test/source_message_posting_worker.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/dom/serviceworkers/test/source_message_posting_worker.js b/dom/serviceworkers/test/source_message_posting_worker.js
new file mode 100644
index 0000000000..8ca6246c51
--- /dev/null
+++ b/dom/serviceworkers/test/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.");
+ }
+};