summaryrefslogtreecommitdiff
path: root/dom/base/test/worker_postMessages.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/test/worker_postMessages.js')
-rw-r--r--dom/base/test/worker_postMessages.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/dom/base/test/worker_postMessages.js b/dom/base/test/worker_postMessages.js
new file mode 100644
index 0000000000..968ec209a2
--- /dev/null
+++ b/dom/base/test/worker_postMessages.js
@@ -0,0 +1,33 @@
+function test_workers() {
+ onmessage = function(e) {
+ postMessage(e.data, e.ports);
+ }
+}
+
+function test_broadcastChannel() {
+ var bc = new BroadcastChannel('postMessagesTest_inWorkers');
+ bc.onmessage = function(e) {
+ postMessage(e.data);
+ }
+}
+
+function test_messagePort(port) {
+ port.onmessage = function(e) {
+ postMessage(e.data, e.ports);
+ }
+}
+
+onmessage = function(e) {
+ if (e.data == 'workers') {
+ test_workers();
+ postMessage('ok');
+ } else if (e.data == 'broadcastChannel') {
+ test_broadcastChannel();
+ postMessage('ok');
+ } else if (e.data == 'messagePort') {
+ test_messagePort(e.ports[0]);
+ postMessage('ok');
+ } else {
+ postMessage('ko');
+ }
+}