Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / textarea-caret-position.html
blobc8cea3d24985e0f0248aeaab2668c255f9faf9f9
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 caret position 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 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",
32 caretPosition);
33 shouldBeEqualToNumber("textareaAccessible.selectionEnd",
34 caretPosition);
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");
57 </script>
59 </body>
60 </html>