<html>
<head>
    <script>
    function runTest() {
        if (window.testRunner)
            testRunner.dumpAsText();
        else {
            alert('This test does not work in Safari.');
            return;
        }

        document.getElementById('first').focus();
        
        // This will cause onchange to get invoked
        eventSender.keyDown('a', new Array());

        // Simulate a tab. 
        eventSender.keyDown('\t', new Array());

        document.getElementById('result').innerHTML = "SUCCESS - Didn't crash";
    }
    </script>
</head>
<body onload="runTest()">
    <input id="first" type="text" onchange="document.getElementById('u').style.display='none'"><input id="u" type="text">
    <p>This tests that setting display to 'none' for an element that's about to get focus doesn't crash.</p>
    <div id="result">THE TEST DID NOT RUN</div>
</body>
</html>
