Html程序  |  58行  |  2.11 KB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
    <script type="text/javascript">
        var inner_win;

        function open_inner()
        {
            var src = 'data:text/html,<title>Pop up</title><input type="button" value="Close" onclick="opener.closeChild()">';
            var tp = document.getElementById("theparent");
            inner_win = window.open(src, 'inner', 'width=200, height=200, left=' + (screenLeft + tp.offsetLeft) + ', top=' + (screenTop + outerHeight - innerHeight + tp.offsetTop));
        }

        function removeHoverNode()
        {
            var tp = document.getElementById("theparent");
            tp.parentNode.removeChild(tp);
            setTimeout(reportSuccess, 500);
        }

        function reportSuccess()
        {
            document.body.appendChild(document.createTextNode("SUCCESS"));
        }

        function closeChild()
        {
            inner_win.close();
            document.body.offsetTop;
            setTimeout(removeHoverNode, 100);
        }
    </script>
</head>
<body>
<p><b>BUG ID:</b> <a href="rdar://problem/5095977">5095997</a> (<a href="http://bugs.webkit.org/show_bug.cgi?id=13218">13218</a>) Reproducible crash after call to window.close()</p>

<p id="test" style="background-color:skyblue; padding:3px;"><b>STEPS TO TEST:</b><br>
    1. Click the Open button below. A pop up window will open.<br>
    2. In the pop up window, click the Close button, being careful not to
    move the mouse during and shortly after clicking.
</p>

<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b> 
    The black square will be replaced by the word &ldquo;SUCCESS&rdquo; and Safari will not crash.
</p>

<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>  
    Safari will crash (the word &ldquo;SUCCESS&rdquo; may appear before the crash).
</p>
    <div id='theparent'>
        <input type="button" value="Open" onclick="open_inner()">
        <div style="background: black; width: 200px; height:200px">
        </div>
    </div>
</body>
</html>