Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / inline-text-textarea.html
blobd98a4185c15f229ab088907fd78b20b3a2105c42
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 </head>
6 <body>
8 <textarea id="textarea" cols=30 rows=20>This textarea contains several lines of text. It demonstrates
9 how updating a single InlineTextBox is a lot more efficient than updating the whole TextArea.</textarea>
11 <p id="description"></p>
13 <div id="console"></div>
15 <script>
17 description("Demonstrates that when typing in a textarea, not all of the InlineTextBoxes need to be updated for every character pressed.");
19 if (window.accessibilityController) {
21 function findAllDescendantsWithRole(axObject, role) {
22 if (axObject.role == role)
23 return [axObject];
24 var result = [];
25 for (var i = 0; i < axObject.childrenCount; i++)
26 result = result.concat(findAllDescendantsWithRole(axObject.childAtIndex(i), role));
27 return result;
30 var axTextarea = accessibilityController.accessibleElementById('textarea');
31 var inlineTextBoxesBefore = findAllDescendantsWithRole(axTextarea, 'AXRole: AXInlineTextBox');
32 var firstInlineTextBoxBefore = inlineTextBoxesBefore[0];
33 var lastInlineTextBoxBefore = inlineTextBoxesBefore[inlineTextBoxesBefore.length - 1];
35 document.getElementById("textarea").focus();
36 document.getElementById("textarea").setSelectionRange(45, 45);
38 // Insert a character in the first paragraph.
39 document.execCommand("InsertText", false, 'x');
41 // The inline text boxes in the first paragraph change, but the
42 // inline text boxes in the last paragraph are reused.
43 var inlineTextBoxesAfter = findAllDescendantsWithRole(axTextarea, 'AXRole: AXInlineTextBox');
44 var firstInlineTextBoxAfter = inlineTextBoxesAfter[0];
45 var lastInlineTextBoxAfter = inlineTextBoxesAfter[inlineTextBoxesAfter.length - 1];
47 shouldBe("firstInlineTextBoxBefore.isEqual(firstInlineTextBoxAfter)", "false");
48 shouldBe("lastInlineTextBoxBefore.isEqual(lastInlineTextBoxAfter)", "true");
50 </script>
52 </body>
53 </html>