blob: bcb5f1cdd2a0f4c1e1414ebbb91fb64e46da163e [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script>
description("This tests that 'input' event listener gets correct caret position after keypress.");
var test = document.createElement("input")
document.body.appendChild(test);
test.focus();
const backSpace = String.fromCharCode(8);
var input = ["a", "b", "c", backSpace, backSpace, backSpace];
var output = ["", "a", "ab", "abc", "ab", "a", ""];
function dumpState() {
var expectedValue = output.shift();
shouldBeEqualToString("test.value", expectedValue);
shouldBe("test.selectionStart", "" + expectedValue.length);
shouldBe("test.selectionEnd", "" + expectedValue.length);
debug("");
}
test.addEventListener("input", dumpState);
dumpState();
while (input.length)
eventSender.keyDown(input.shift());
</script>
</body>
</html>