<html>
<body onload="startTest()">
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=18595">bug 18595</a>:
Setting display:none on an iframe causes the ownerDocument to freeze.</p>
<div id="log">Please do what links below say:</div>
<a id=foo href="javascript:pass()"></a>
<iframe src="about:blank"></iframe>
<script>
if (window.testRunner) {
    testRunner.waitUntilDone();
    testRunner.dumpAsText();
}

var iframe = document.getElementsByTagName("iframe")[0];

function startTest()
{
    var doc = iframe.contentDocument;
    var a = doc.createElement('a');
    a.href='#';
    a.onmousedown=function(){
       document.getElementById('foo').appendChild(document.createTextNode('Now click me'));
       iframe.style.display='none';
    };
    a.appendChild(document.createTextNode('Click me'));
    doc.body.appendChild(a);

    if (window.eventSender) {
       var x = iframe.offsetLeft + a.offsetLeft + 7;
       var y = iframe.offsetTop + a.offsetTop + 7;
       eventSender.mouseMoveTo(x, y);
       eventSender.mouseDown();
       eventSender.mouseUp();
       setTimeout(click2, 10);
    }
}

function click2()
{
    var foo = document.getElementById("foo");
    var x = foo.offsetLeft + 7;
    var y = foo.offsetTop + 7;
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseUp();
}

function pass()
{
    document.getElementById("log").innerHTML = "PASS";
    document.getElementById("foo").innerHTML = "";

    if (window.testRunner)
        testRunner.notifyDone();
}

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