<html>
<script>
    function log(msg) {
        var res = document.getElementById('res');
        res.innerHTML = res.innerHTML + msg + "<br>";
    }
    function test() {
        var tf0 = document.getElementById('tf0');
        var fr = document.getElementById('fr');
        var tf1 = fr.contentDocument.getElementById('tf1');
        tf0.focus();
        if (window.testRunner) {
            testRunner.dumpAsText();
            eventSender.keyDown("1");
            eventSender.keyDown("2");
            eventSender.keyDown("3");
        }
        if (tf0.value == "1" && tf1.value == "23") {
            res.innerHTML = "Test Passed";
        } else {
            res.innerHTML = "Test Failed: first field = " + tf0.value + "  second field = " + tf1.value;
        }
    }

</script> 
<body onload="test()">
    This tests that when the keyPress event handler changes focus to a new form field,<br>
    that the key will still be inserted in the original field that was the target of the event.<br>
    <input id="tf0" onkeypress="document.getElementById('fr').contentDocument.getElementById('tf1').focus();">
    <iframe id="fr" style="border: solid thin black;" src="resources/keypress-frame.html"></iframe>
    <br>
    <div id="res"></div>
</body>
</html>
