blob: f6a31f24964ba108948405ae8e94e25c51a17450 [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<title id="desc">HTML5 Selection: Call select() on a text field</title>
<script type="text/javascript">
var testPassed = true;
function checkDefaultSelectionAttributes()
{
var selection = window.getSelection();
if (null != selection.anchorNode)
{
testPassed = false;
}
if (0 != selection.anchorOffset)
{
testPassed = false;
}
if (null != selection.focusNode)
{
testPassed = false;
}
if (0 != selection.focusOffset)
{
testPassed = false;
}
if (!selection.isCollapsed)
{
testPassed = false;
}
if (0 != selection.rangeCount)
{
testPassed = false;
}
}
function RunTest()
{
try
{
var input1 = document.getElementById("input1");
input1.select();
checkDefaultSelectionAttributes();
var selectionText = input1.value.substring(input1.selectionStart, input1.selectionEnd);
if (input1.value != selectionText)
{
testPassed = false;
}
if (testPassed)
{
document.getElementById("testresult").firstChild.data = "PASS";
}
}
catch (ex)
{
document.getElementById("testresult").firstChild.data = "FAIL";
}
}
</script>
</head>
<body onload="RunTest();">
<input style="WIDTH: 500px" id="input1" value="Some text in an input control" type="text" />
<p>Select the text in the input element by calling select()</p>
<p>Test passes if the word "PASS" appears below.</p>
<div>Test result: </div>
<div id="testresult">FAIL</div>
</body>
</html>