blob: 083a80d7b38054fe362ac9b0c728cc8be5fee26e [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<body>
<script src="../../fast/js/resources/js-test-pre.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>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>