diff options
Diffstat (limited to '')
-rw-r--r-- | testing/web-platform/tests/webmessaging/Channel_postMessage_with_transfer_outgoing_messages.any.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webmessaging/Channel_postMessage_with_transfer_outgoing_messages.any.js b/testing/web-platform/tests/webmessaging/Channel_postMessage_with_transfer_outgoing_messages.any.js new file mode 100644 index 0000000000..aa80b7589c --- /dev/null +++ b/testing/web-platform/tests/webmessaging/Channel_postMessage_with_transfer_outgoing_messages.any.js @@ -0,0 +1,35 @@ + +async_test(function(t) { + var channel1 = new MessageChannel(); + var channel2 = new MessageChannel(); + var channel3 = new MessageChannel(); + channel2.port2.onmessage = t.step_func(function (evt) { + evt.ports[0].postMessage("Second"); + evt.ports[0].postMessage("Third"); + channel3.port1.onmessage = t.step_func(function (evt) { + evt.ports[0].postMessage("Fourth"); + }); + channel3.port2.postMessage("2", evt.ports); + }); + channel1.port1.postMessage("First"); + channel2.port1.postMessage("1", [channel1.port1]); + var counter = 0; + channel1.port2.onmessage = t.step_func(function (evt) { + if (counter == 0) { + assert_equals(evt.data, "First"); + counter = 1; + } else if (counter == 1) { + assert_equals(evt.data, "Second"); + counter = 2; + } + else if (counter == 2) { + assert_equals(evt.data, "Third"); + counter = 3; + } + else if (counter == 3) { + assert_equals(evt.data, "Fourth"); + t.done(); + } + }); +}, `When transferring a port, + outgoing messages sent at each transfer step are received in order by the entangled port.`); |