OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <script src="../../fast/js/resources/js-test-pre.js"></script> | 4 <script src="../../fast/js/resources/js-test-pre.js"></script> |
5 <script> | 5 <script> |
6 description("This tests that 'input' event listener gets correct caret position
after keypress."); | 6 description("This tests that 'input' event listener gets correct caret position
after keypress."); |
7 | 7 |
8 var test = document.createElement("input") | 8 var test = document.createElement("input") |
9 document.body.appendChild(test); | 9 document.body.appendChild(test); |
10 test.focus(); | 10 test.focus(); |
11 | 11 |
12 const backSpace = String.fromCharCode(8); | 12 const backSpace = String.fromCharCode(8); |
13 var input = ["a", "b", "c", backSpace, backSpace, backSpace]; | 13 var input = ["a", "b", "c", backSpace, backSpace, backSpace]; |
14 var output = ["", "a", "ab", "abc", "ab", "a", ""]; | 14 var output = ["", "a", "ab", "abc", "ab", "a", ""]; |
15 | 15 |
16 function dumpState() { | 16 function dumpState() { |
17 var expectedValue = output.shift(); | 17 var expectedValue = output.shift(); |
18 shouldBeEqualToString("test.value", expectedValue); | 18 shouldBeEqualToString("test.value", expectedValue); |
19 shouldBe("test.selectionStart", "" + expectedValue.length); | 19 shouldBe("test.selectionStart", "" + expectedValue.length); |
20 shouldBe("test.selectionEnd", "" + expectedValue.length); | 20 shouldBe("test.selectionEnd", "" + expectedValue.length); |
21 debug(""); | 21 debug(""); |
22 } | 22 } |
23 | 23 |
24 test.addEventListener("input", dumpState); | 24 test.addEventListener("input", dumpState); |
25 dumpState(); | 25 dumpState(); |
26 while (input.length) | 26 while (input.length) |
27 eventSender.keyDown(input.shift()); | 27 eventSender.keyDown(input.shift()); |
28 </script> | 28 </script> |
29 <script src="../../fast/js/resources/js-test-post.js"></script> | |
30 </body> | 29 </body> |
31 </html> | 30 </html> |
OLD | NEW |