blob: ca5c97f682e6405f398fce4a924019b3df018d95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<html>
<head>
<style>
textarea { -webkit-appearance: textarea;}
</style>
<script>
function log(msg) {
document.getElementById('res').innerHTML = document.getElementById('res').innerHTML + msg + "<br>";
}
function test() {
if (window.testRunner)
testRunner.dumpAsText();
var ta = document.getElementById('ta');
log('Calling focus on textarea');
ta.focus();
log('After focus: textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd + '<br>');
log('Calling setSelectionRange on textarea');
ta.setSelectionRange(5, 10);
log('After setSelectionRange(5, 10): textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd + '<br>');
log('Double clicking to make selection for textarea');
if (window.eventSender) {
eventSender.mouseMoveTo(75, 55);
eventSender.mouseDown();
eventSender.mouseUp();
eventSender.mouseDown();
eventSender.mouseUp();
}
log('After double clicking: textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd + '<br>');
log('Calling blur on textarea');
ta.blur();
log('After blur: textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd + '<br>');
log('Calling focus on textarea');
ta.focus();
log('After focus: textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd);
}
</script>
</head>
<body onload="test()">
<br>
This tests onSelect for textareas. <br>
This also makes sure that the correct selection is restored when the element regains focus.<br><br>
<textarea id="ta" onselect="log('onselect fired for textarea');" style="position: absolute; top: 50; left: 10;">textarea with lots of fun content!</textarea>
<div id="res" style="position: absolute; top: 100; left: 10;"></div>
</body>
</html>
|