<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<p>Tests behavior of code that clears the text from a focused editable div. 
<br><br>To run manually press any key to clear the text in the div.<br>The key that was typed should replace the text in the editable div and div should still have the focus and a blinking caret.</p>
<div id="it" style="-webkit-user-modify: read-write;" onkeydown="resetIt(event)" onkeypress="typedChar(event)" onkeyup="checkResult(event)">text</div>
<p id="result">TEST NOT RUN YET</p>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

var it = document.getElementById("it");
it.focus();

function resetIt(event) {
    var it = document.getElementById("it");
    it.innerText = '';
    it.focus();
}

var lastTypedChar = '';
function typedChar(event) {
    lastTypedChar = String.fromCharCode(event.keyCode);
}

function checkResult(event) {
    if (lastTypedChar != '') {
        var text = document.getElementById("it").innerText;  
        if (text != lastTypedChar)
            document.getElementById("result").innerHTML = "FAIL: editable div content is '" + text + "' and it should be '" + lastTypedChar + "'" ;
        else
            document.getElementById("result").innerHTML = "PASS";
    }
}

if (window.eventSender)
    eventSender.keyDown("a");
</script>
</body>
</html>
