4 <script src=
"../resources/js-test.js"></script>
8 <textarea id=
"textarea" rows=
"3" cols=
"40">
14 <textarea id=
"textarea-empty" rows=
"5" cols=
"40"></textarea>
17 description("This tests that caret position is reported correctly for textarea elements.");
19 if (window
.accessibilityController
) {
21 var textarea
= document
.getElementById('textarea');
23 var textareaAccessible
=
24 accessibilityController
.accessibleElementById('textarea');
26 for (var i
= 0; i
< 3; ++i
) {
27 for (var j
= 0; j
< 7; ++j
) {
28 var caretPosition
= i
* 7 + j
;
29 textarea
.selectionStart
= caretPosition
;
30 textarea
.selectionEnd
= caretPosition
;
31 shouldBeEqualToNumber("textareaAccessible.selectionStart",
33 shouldBeEqualToNumber("textareaAccessible.selectionEnd",
35 shouldBeEqualToNumber("textareaAccessible.selectionStartLineNumber", i
);
36 shouldBeEqualToNumber("textareaAccessible.selectionEndLineNumber", i
);
40 var emptyTextarea
= document
.getElementById('textarea-empty');
41 emptyTextarea
.focus();
42 // Each textarea has its own independent caret.
43 shouldBeEqualToNumber("textareaAccessible.selectionStart", 20);
44 shouldBeEqualToNumber("textareaAccessible.selectionEnd", 20);
46 var emptyTextareaAccessible
=
47 accessibilityController
.accessibleElementById('textarea-empty');
48 shouldBeZero("emptyTextareaAccessible.selectionStart");
49 shouldBeZero("emptyTextareaAccessible.selectionEnd");
51 // Setting the caret at an invalid offset should not move it.
52 emptyTextarea
.setSelectionRange(1, 1);
53 shouldBeZero("emptyTextareaAccessible.selectionStart");
54 shouldBeZero("emptyTextareaAccessible.selectionEnd");