Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / textarea-selection.html
blob6067e3f8854417782db98fc667f260d546d520f1
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 </head>
6 <body>
8 <textarea id="textarea" rows="3" cols="40">
9 Line 1
10 Line 2
11 Line 3
12 </textarea>
14 <textarea id="textarea-empty" rows="5" cols="40"></textarea>
16 <script>
17 description("This tests that text selection is reported correctly for textarea elements.");
19 if (window.accessibilityController) {
21 var textarea = document.getElementById('textarea');
22 textarea.focus();
23 var textareaAccessible =
24 accessibilityController.accessibleElementById('textarea');
26 // Select the entire contents.
27 textarea.select();
28 shouldBeZero("textareaAccessible.selectionStart");
29 shouldBeEqualToNumber("textareaAccessible.selectionEnd",
30 textarea.textLength);
31 shouldBeZero("textareaAccessible.selectionStartLineNumber");
32 shouldBeEqualToNumber(
33 "textareaAccessible.selectionEndLineNumber",
34 3);
36 // Select entire lines.
37 for (var lineNumber = 0; lineNumber < 3; ++lineNumber) {
38 for (var directionIndex = 0; directionIndex < 2;
39 ++directionIndex) {
40 var selectionStart = lineNumber * 7;
41 var selectionEnd = (lineNumber + 1) * 7;
42 var direction = 'forward';
43 if (directionIndex)
44 direction = 'backward';
46 textarea.setSelectionRange(selectionStart, selectionEnd,
47 direction);
48 shouldBeEqualToNumber("textareaAccessible.selectionStart",
49 selectionStart);
50 shouldBeEqualToNumber("textareaAccessible.selectionEnd",
51 selectionEnd);
52 shouldBeEqualToNumber(
53 "textareaAccessible.selectionStartLineNumber",
54 lineNumber);
55 shouldBeEqualToNumber(
56 "textareaAccessible.selectionEndLineNumber",
57 lineNumber + 1);
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");
86 </script>
88 </body>
89 </html>