| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <script src="../resources/js-test.js"></script> |
| </head> |
| <body> |
| |
| <!-- Note: the xxxxxx... should wrap onto another line on all platforms. --> |
| <p id="paragraph" style="width: 8em; word-wrap: break-word;"> |
| Ace ten twenty-one thirty-five. xxxxxxxxxxxxxxxxxxx |
| </p> |
| |
| <p id="description"></p> |
| |
| <div id="console"></div> |
| |
| <script> |
| |
| description("Tests that we can compute word boundaries for any character index from the accessibility tree."); |
| |
| // Note: all that matters is that characters within actual words are mapped correctly. |
| // Whether a character between words is mapped to the previous or next word is arbitrary; |
| // all that matters is that we expose the start and end of real words. |
| if (window.accessibilityController) { |
| var axParagraph = accessibilityController.accessibleElementById('paragraph'); |
| var axStaticText = axParagraph.childAtIndex(0); |
| var text = axStaticText.name; |
| debug("Accessible text: \"" + text + "\""); |
| |
| for (var i = 0; i < text.length; i++) { |
| // Get the bounds from the accessibility tree. |
| var wordStart = axStaticText.wordStart(i); |
| var wordEnd = axStaticText.wordEnd(i); |
| debug("Character " + i + ": '" + text.substr(i, 1) + |
| "' word=(" + wordStart + ", " + wordEnd + "): '" + |
| text.substr(wordStart, wordEnd - wordStart) + "'"); |
| } |
| } |
| </script> |
| |
| </body> |
| </html> |