blob: 0746a3eedee8e65c6b64aa7fea5a789cb28a85a5 [file] [log] [blame]
<html>
<style>
/* Add space between div and textfield so that touch selects the text in div. */
#textDiv {
margin-bottom: 30px;
}
</style>
<body>
<div id='dummy'>Dummy Padding Text</div>
<div id='textDiv'>Some text we can select</div>
<div id='dummy'>Dummy Padding Text</div>
<input id='textfield' type="text" value="Text in a textfield">
</body>
<script>
function focus_textfield() {
document.getElementById('textfield').focus();
// Focusing the textfiled selects its text. Collapse selection to a cursor.
window.getSelection().collapseToStart();
}
function get_point_inside(element) {
var rect = element.getBoundingClientRect();
var point = {
x: rect.left + 8,
y: rect.top + 8
};
window.domAutomationController.send(JSON.stringify(point));
}
function get_point_inside_text() {
get_point_inside(document.getElementById('textDiv'));
}
function get_point_inside_textfield() {
get_point_inside(document.getElementById('textfield'));
}
</script>
</html>