OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 | |
8 <textarea id="textarea" rows="3" cols="40"> | |
9 Line 1 | |
10 Line 2 | |
11 Line 3 | |
12 </textarea> | |
13 | |
14 <textarea id="textarea-empty" rows="5" cols="40"></textarea> | |
15 | |
16 <p id="description"></p> | |
17 <div id="console"></div> | |
18 | |
19 <script> | |
20 description("This tests that text selection is reported correctly for te
xtarea elements."); | |
21 | |
22 if (window.accessibilityController) { | |
23 | |
24 var textarea = document.getElementById('textarea'); | |
25 textarea.focus(); | |
26 var textareaAccessible = | |
27 accessibilityController.accessibleElementById('textarea'); | |
28 | |
29 // Select the entire contents. | |
30 textarea.select(); | |
31 shouldBeZero("textareaAccessible.selectionStart"); | |
32 shouldBeEqualToNumber("textareaAccessible.selectionEnd", | |
33 textarea.textLength); | |
34 shouldBeZero("textareaAccessible.selectionStartLineNumber"); | |
35 shouldBeEqualToNumber( | |
36 "textareaAccessible.selectionEndLineNumber", | |
37 3); | |
38 | |
39 // Select entire lines. | |
40 for (var lineNumber = 0; lineNumber < 3; ++lineNumber) { | |
41 for (var directionIndex = 0; directionIndex < 2; | |
42 ++directionIndex) { | |
43 var selectionStart = lineNumber * 7; | |
44 var selectionEnd = (lineNumber + 1) * 7; | |
45 var direction = 'forward'; | |
46 if (directionIndex) | |
47 direction = 'backward'; | |
48 | |
49 textarea.setSelectionRange(selectionStart, selectionEnd, | |
50 direction); | |
51 shouldBeEqualToNumber("textareaAccessible.selectionStart", | |
52 selectionStart); | |
53 shouldBeEqualToNumber("textareaAccessible.selectionEnd", | |
54 selectionEnd); | |
55 shouldBeEqualToNumber( | |
56 "textareaAccessible.selectionStartLineNumber", | |
57 lineNumber); | |
58 shouldBeEqualToNumber( | |
59 "textareaAccessible.selectionEndLineNumber", | |
60 lineNumber + 1); | |
61 } | |
62 } | |
63 | |
64 var emptyTextarea = document.getElementById('textarea-empty'); | |
65 emptyTextarea.focus(); | |
66 // Each textarea has its own independent selection. | |
67 shouldBeEqualToNumber("textareaAccessible.selectionStart", 14); | |
68 shouldBeEqualToNumber("textareaAccessible.selectionEnd", 21); | |
69 shouldBeEqualToNumber( | |
70 "textareaAccessible.selectionStartLineNumber", 2); | |
71 shouldBeEqualToNumber( | |
72 "textareaAccessible.selectionEndLineNumber", 3); | |
73 | |
74 var emptyTextareaAccessible = | |
75 accessibilityController.accessibleElementById('textarea-empty'); | |
76 shouldBeZero("emptyTextareaAccessible.selectionStart"); | |
77 shouldBeZero("emptyTextareaAccessible.selectionEnd"); | |
78 shouldBeZero("emptyTextareaAccessible.selectionStartLineNumber"); | |
79 shouldBeZero("emptyTextareaAccessible.selectionEndLineNumber"); | |
80 | |
81 // Setting an invalid selection should not be visible. | |
82 emptyTextarea.setSelectionRange(1, 1); | |
83 shouldBeZero("emptyTextareaAccessible.selectionStart"); | |
84 shouldBeZero("emptyTextareaAccessible.selectionEnd"); | |
85 shouldBeZero("emptyTextareaAccessible.selectionStartLineNumber"); | |
86 shouldBeZero("emptyTextareaAccessible.selectionEndLineNumber"); | |
87 | |
88 } | |
89 </script> | |
90 | |
91 </body> | |
92 </html> | |
OLD | NEW |