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 text selection is reported correctly for textarea elements.");
19 if (window
.accessibilityController
) {
21 var textarea
= document
.getElementById('textarea');
23 var textareaAccessible
=
24 accessibilityController
.accessibleElementById('textarea');
26 // Select the entire contents.
28 shouldBeZero("textareaAccessible.selectionStart");
29 shouldBeEqualToNumber("textareaAccessible.selectionEnd",
31 shouldBeZero("textareaAccessible.selectionStartLineNumber");
32 shouldBeEqualToNumber(
33 "textareaAccessible.selectionEndLineNumber",
36 // Select entire lines.
37 for (var lineNumber
= 0; lineNumber
< 3; ++lineNumber
) {
38 for (var directionIndex
= 0; directionIndex
< 2;
40 var selectionStart
= lineNumber
* 7;
41 var selectionEnd
= (lineNumber
+ 1) * 7;
42 var direction
= 'forward';
44 direction
= 'backward';
46 textarea
.setSelectionRange(selectionStart
, selectionEnd
,
48 shouldBeEqualToNumber("textareaAccessible.selectionStart",
50 shouldBeEqualToNumber("textareaAccessible.selectionEnd",
52 shouldBeEqualToNumber(
53 "textareaAccessible.selectionStartLineNumber",
55 shouldBeEqualToNumber(
56 "textareaAccessible.selectionEndLineNumber",
61 var emptyTextarea
= document
.getElementById('textarea-empty');
62 emptyTextarea
.focus();
63 // Each textarea has its own independent selection.
64 shouldBeEqualToNumber("textareaAccessible.selectionStart", 14);
65 shouldBeEqualToNumber("textareaAccessible.selectionEnd", 21);
66 shouldBeEqualToNumber(
67 "textareaAccessible.selectionStartLineNumber", 2);
68 shouldBeEqualToNumber(
69 "textareaAccessible.selectionEndLineNumber", 3);
71 var emptyTextareaAccessible
=
72 accessibilityController
.accessibleElementById('textarea-empty');
73 shouldBeZero("emptyTextareaAccessible.selectionStart");
74 shouldBeZero("emptyTextareaAccessible.selectionEnd");
75 shouldBeZero("emptyTextareaAccessible.selectionStartLineNumber");
76 shouldBeZero("emptyTextareaAccessible.selectionEndLineNumber");
78 // Setting an invalid selection should not be visible.
79 emptyTextarea
.setSelectionRange(1, 1);
80 shouldBeZero("emptyTextareaAccessible.selectionStart");
81 shouldBeZero("emptyTextareaAccessible.selectionEnd");
82 shouldBeZero("emptyTextareaAccessible.selectionStartLineNumber");
83 shouldBeZero("emptyTextareaAccessible.selectionEndLineNumber");