chromium/third_party/blink/web_tests/editing/selection/5213963.html

<p>This tests to see that a selection inside an input field is removed when clicking (and focusing) a button in the same frame.</p>
<input id="input" type="text" value="After you click the button below, this content should not be selected." size="60"><br>
<input id="button" type="button" value="Click Me"><br>
<ul id="console"></ul>

<script>
function log(msg) {
    console = document.getElementById("console");
    li = document.createElement("li");
    text = document.createTextNode(msg);
    console.appendChild(li);
    li.appendChild(text);
}

if (window.testRunner)
    testRunner.dumpAsText();
var input = document.getElementById("input");
input.focus();
input.setSelectionRange(0, input.value.length);
if (!input.selectionEnd)
    log("Failure: There was no selection inside the input field when the test began.");
if (!window.eventSender)
    log("Test not run because there is no event sender.");
else {
    var button = document.getElementById("button");
    var x = button.offsetParent.offsetLeft + button.offsetLeft + button.offsetWidth / 2;
    var y = button.offsetParent.offsetTop + button.offsetTop + button.offsetHeight / 2;
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseUp();
    if (!input.selectionEnd)
        log("Failure: There was still a selection after clicking a button.");
    log("Success");
}
</script>