Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / message-port-start-and-close-different-microtask.html
blobca440fe80c38464ffd3a89f64068ff691651d2f5
1 <body>
2 <p>Test whether opening and closing a messageport in different microtasks correctly receives an in-flight message.</p>
3 <p>Should be a START message, followed by a HELLO message then DONE.</p>
4 <pre id=log></pre>
5 <script>
6 function log(message)
8 document.getElementById("log").innerHTML += message + "<br>";
11 if (window.testRunner) {
12 testRunner.dumpAsText();
13 testRunner.waitUntilDone();
16 log("START");
18 var channel = new MessageChannel;
19 channel.port2.postMessage("HELLO");
20 openThenPostClose();
21 done();
23 function openThenPostClose() {
24 setTimeout(function() {
25 channel.port1.onmessage = function(evt) {
26 log("PASS. Got Message: " + evt.data + " before close");
28 setTimeout(function() {
29 channel.port1.close();
30 }, 0);
31 }, 0);
34 function done() {
35 // Wait a short period of time to ensure no messages come in from previous tests.
36 setTimeout(function() {
37 log("DONE");
38 if (window.testRunner)
39 testRunner.notifyDone();
40 }, 100);
43 </script>
44 </body>