49 lines
1.7 KiB
HTML
49 lines
1.7 KiB
HTML
<html>
|
|
<script type="text/javascript">
|
|
|
|
function print(message)
|
|
{
|
|
var paragraph = document.createElement("div");
|
|
if (message == "")
|
|
paragraph.appendChild(document.createElement("br"));
|
|
else
|
|
paragraph.appendChild(document.createTextNode(message));
|
|
document.getElementById("console").appendChild(paragraph);
|
|
}
|
|
|
|
function test()
|
|
{
|
|
if (window.testRunner)
|
|
testRunner.dumpAsText();
|
|
|
|
testElement(document.getElementById("textarea"));
|
|
testElement(document.getElementById("input"));
|
|
}
|
|
|
|
function testElement(element)
|
|
{
|
|
element.focus();
|
|
element.value = "This is a test value.";
|
|
element.setSelectionRange(3,7);
|
|
element.focus();
|
|
if (element.selectionStart == 3)
|
|
print("Passed.");
|
|
else
|
|
print("Failed, selection of " + element + " is " + element.selectionStart + "-" + element.selectionEnd + ".");
|
|
element.blur();
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body onload="test();">
|
|
<p>This test checks if a call to focus on an already-focused element causes a change in selection.</p>
|
|
<p>If the test passes for both textarea and text input elements you'll see two messages saying "passed" below.</p>
|
|
<hr>
|
|
<p id="console"></p>
|
|
<hr>
|
|
<form>
|
|
<p><textarea id="textarea" cols="20"></textarea></p>
|
|
<p><input type="text" id="input" size="20"></p>
|
|
</form>
|
|
</body>
|
|
</html> |