| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../resources/js-test.js"></script> |
| </head> |
| <body> |
| |
| <input type="text" id="input" value="Line 1"> |
| |
| <script> |
| description("This tests that text selection is reported correctly for text input elements."); |
| |
| if (window.accessibilityController) { |
| |
| let input = document.getElementById('input'); |
| input.focus(); |
| window.inputAccessible = |
| accessibilityController.accessibleElementById('input'); |
| |
| // Select the entire contents. |
| input.select(); |
| shouldBe("inputAccessible", "inputAccessible.selectionAnchorObject"); |
| shouldBeZero("inputAccessible.selectionAnchorOffset"); |
| shouldBe("inputAccessible", "inputAccessible.selectionFocusObject"); |
| shouldBeEqualToNumber("inputAccessible.selectionFocusOffset", 6); |
| |
| // Select all possible text ranges. |
| for (let start = 0; start < 7; ++start) { |
| for (let end = start + 1; end < 7; ++end) { |
| input.setSelectionRange(start, end); |
| shouldBe("inputAccessible", "inputAccessible.selectionAnchorObject"); |
| shouldBeEqualToNumber("inputAccessible.selectionAnchorOffset", start); |
| shouldBe("inputAccessible", "inputAccessible.selectionFocusObject"); |
| shouldBeEqualToNumber("inputAccessible.selectionFocusOffset", end); |
| } |
| } |
| |
| } |
| </script> |
| |
| </body> |
| </html> |