<!DOCTYPE html>
<html>
<body>
<script>

if (window.testRunner)
    testRunner.dumpAsText();

function prepare() {
    var iframe = document.createElement('iframe');
    document.body.appendChild(iframe);
    var doc = iframe.contentDocument;
    doc.body.innerHTML = '<div>hello</div>';
    doc.execCommand('SelectAll', false, null);
    iframe.style.width = '50px';
    iframe.style.height = '50px';
    iframe.offsetLeft; // Force layout
    iframe.style.width = '200%';
    iframe.style.height = '200%';
    return iframe.contentWindow.getSelection();
}

document.body.addEventListener('overflowchanged', function () {
    document.body.innerHTML = 'This tests removing the iframe for which overflowchanged is dispatched. WebKit should not crash.';
    GCController.collect();
    setTimeout(function () {
        document.body.innerHTML += '<br><br>PASS.';
        testRunner.notifyDone();
    }, 0);
});

if (window.GCController) {
    testRunner.waitUntilDone();
    prepare().collapseToStart();
} else
    document.write('This test requires GCController.');

</script>
</body>
</html>
