| This tests to make sure that clicking inside a text field places the caret in it, even if the fields focus handler scrolls the document. Click inside the text field and verify that the caret is placed where you click.<br> |
| <input id="textfield" onFocus="window.scrollBy(0, 40)" value="click in me"><br> |
| <div style="height: 1500px;"> |
| <script> |
| if (window.testRunner) { |
| window.testRunner.dumpAsText(); |
| textfield = document.getElementById("textfield"); |
| // Click near the end of the field so that the caret after all of the text inside it. |
| x = textfield.offsetParent.offsetLeft + textfield.offsetLeft + textfield.offsetWidth - 5; |
| y = textfield.offsetParent.offsetTop + textfield.offsetTop + textfield.offsetHeight / 2; |
| eventSender.mouseMoveTo(x, y); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| if (textfield.selectionStart == textfield.value.length && textfield.selectionEnd == textfield.value.length) |
| document.body.innerText = "Success" |
| else |
| document.body.innerText = "Failure. Expected selection to be after all of the text in the text field." |
| } |
| </script> |