<!DOCTYPE html>
<body>
<script src="../../resources/js-test.js"></script>
<script>
jsTestIsAsync = true;
description("MessagePorts (and their execution contexts) should be collected by GC once close() has been called on them");
function runTest() {
    var channel = new MessageChannel();
    var port = channel.port1;
    port.onmessage = function() {
        iframeDocGC = internals.observeGC(document.querySelector('iframe').contentDocument);
        document.querySelector('iframe').remove();
        asyncGC(function() {
            shouldBeTrue("iframeDocGC.wasCollected");
            finishJSTest();
        });
    };
    window.frames[0].postMessage("connect", "*", [channel.port2]);
}
</script>
<iframe src="resources/message-port-gc-closed-cloned-iframe.html" onload="runTest()"></iframe>
</body>
