diff options
Diffstat (limited to 'dom/messagechannel/tests/unit/chromeWorker_messageChannel.js')
-rw-r--r-- | dom/messagechannel/tests/unit/chromeWorker_messageChannel.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/dom/messagechannel/tests/unit/chromeWorker_messageChannel.js b/dom/messagechannel/tests/unit/chromeWorker_messageChannel.js new file mode 100644 index 0000000000..3f557a4fb2 --- /dev/null +++ b/dom/messagechannel/tests/unit/chromeWorker_messageChannel.js @@ -0,0 +1,14 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +onmessage = function (pingEvt) { + if (pingEvt.data == "ping") { + let { port1, port2 } = new MessageChannel(); + port2.onmessage = helloEvt => { + if (helloEvt.data == "hello") { + helloEvt.ports[0].postMessage("goodbye"); + } + }; + pingEvt.ports[0].postMessage("pong", [port1]); + } +}; |