blob: 2262e8e67cd54e4260037509bd3b46b478664258 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/ui-helper.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<input type="text" id="test" value="Select the last word">
<script>
window.jsTestIsAsync = true;
function testSelectAll()
{
function checkResultAndDone() {
shouldBeZero('document.getElementById("test").selectionStart');
shouldBe('document.getElementById("test").selectionEnd', 'document.getElementById("test").value.length');
document.body.removeChild(document.getElementById("test"));
finishJSTest();
}
document.addEventListener("selectionchange", checkResultAndDone, { once: true });
if (window.testRunner)
UIHelper.keyDown("a", ["metaKey"]);
}
function runTest()
{
let testElement = document.getElementById("test");
console.assert(testElement.value.indexOf("word") !== -1);
function handleFocus() {
document.addEventListener("selectionchange", testSelectAll, { once: true });
testElement.setSelectionRange(testElement.value.indexOf("word"), testElement.value.length);
}
testElement.addEventListener("focus", handleFocus, { once: true });
if (window.testRunner)
UIHelper.activateElement(testElement);
else
testElement.focus();
}
description("This tests that pressing Command + A selects all the text even when there is an existing range selction. To run this test by hand, press Command + A.");
runTest();
</script>
</body>
</html>