<!DOCTYPE html>
<meta charset="utf-8">
<title>crash when closing a MessagePort with messages queued for dispatch</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body>
</body>
<script>
var resolve_done;
let done_promise = new Promise(resolve => resolve_done = resolve);
function done() {
document.querySelector('iframe').remove();
resolve_done();
}
// This test creates an iframe with a SharedWorker that does multiple
// postMessages back to the iframe. Once a message is received, the
// iframe is removed. The test passes if it does not crash
// https://crbug.com/649616.
promise_test(t => {
const frame = document.createElement('iframe');
frame.src = 'resources/close-context-messageport-crash-iframe.html';
document.body.appendChild(frame);
return done_promise;
}, 'closing a MessagePort with messages queued for dispatch should not crash');
</script>