48 lines
1.7 KiB
HTML
48 lines
1.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
</head>
|
|
<body>
|
|
<p id="description"></p>
|
|
<input id="text" readonly="readonly" value="2009-04-29"/><br/>
|
|
<textarea id="area" readonly="readonly">2009-04-29</textarea></div>
|
|
<div id="console"></div>
|
|
<div>
|
|
<script type="text/javascript">
|
|
description('Tests for selectionStart and selectionEnd on read-only INPUT and TEXTAREA. <br/> <a href="https://bugs.webkit.org/show_bug.cgi?id=25444">bug 25444</a>: SelectionStart, selectionEnd properties return wrong values when the selection is in a form input.');
|
|
|
|
function startTest(element, start, end) {
|
|
element.setSelectionRange(start, end);
|
|
|
|
start = start < 0 ? 0 : start;
|
|
end = end > 10 ? 10 : end;
|
|
start = start > end ? end : start;
|
|
|
|
if (element.selectionStart != start)
|
|
testFailed('element.selectionStart' + ' should be ' + start + ' but it is ' + element.selectionStart);
|
|
else
|
|
testPassed('element.selectionStart' + ' is ' + element.selectionStart);
|
|
|
|
if (element.selectionEnd != end)
|
|
testFailed('element.selectionEnd' + ' should be ' + end + ' but it is ' + element.selectionEnd);
|
|
else
|
|
testPassed('element.selectionEnd' + ' is ' + element.selectionEnd);
|
|
}
|
|
|
|
function testHandler(element) {
|
|
var offsets = [[0, 10], [0, 9], [1, 10], [5,5], [8,5], [-1,0], [-1,50]];
|
|
for (var i = 0; i < offsets.length; i++)
|
|
startTest(element, offsets[i][0], offsets[i][1]);
|
|
}
|
|
|
|
testHandler(document.getElementById('text'));
|
|
testHandler(document.getElementById('area'));
|
|
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|
|
|