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