chromium/third_party/blink/web_tests/editing/selection/caret-after-keypress.html

<!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>