chromium/third_party/blink/web_tests/fast/events/message-port-start-and-close-same-microtask.html

<body>
<p>Test whether opening and closing a messageport in the same microtask correctly discards an in-flight message.</p>
<p>Should be a START message, followed with DONE.</p>
<pre id=log></pre>
<script>
function log(message)
{
    document.getElementById("log").innerHTML += message + "<br>";
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

log("START");

var channel = new MessageChannel;
channel.port2.postMessage("This message can't be received");
openThenClose();
done();

function openThenClose() {
    setTimeout(function() {
        channel.port1.onmessage = function(evt) {
            log("Closed port receiving: FAIL. Got Message: " +  evt.data + " after close");
        }
        channel.port1.close();
    }, 0);
}

function done() {
    // Wait a short period of time to ensure no messages come in from previous tests.
    setTimeout(function() {
        log("DONE");
        if (window.testRunner)
            testRunner.notifyDone();
    }, 100);
}

</script>
</body>