OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta charset="utf-8"> | 4 <meta charset="utf-8"> |
5 <script src="../resources/js-test.js"></script> | 5 <script src="../resources/js-test.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 | 8 |
9 <p id="paragraph" style="width: 30em;"> | 9 <p id="paragraph" style="width: 30em;"> |
10 The Hitchhiker's Guide to the | 10 The Hitchhiker's Guide to the |
11 | 11 |
12 Galaxy has a few things to say on the subject of resumés. | 12 Galaxy has a few things to say on the subject of resumés. |
13 A resumé, it says, is about the most massively useful thing an interstellar hitc
h hiker can have. | 13 A resumé, it says, is about the most massively useful thing an interstellar hitc
h hiker can have. |
14 </p> | 14 </p> |
15 | 15 |
16 <p id="description"></p> | 16 <p id="description"></p> |
17 | 17 |
18 <div id="console"></div> | 18 <div id="console"></div> |
19 | 19 |
20 <script> | 20 <script> |
21 | 21 |
22 description("Tests that we can compute the bounds of a range of text from th
e accessibility tree."); | 22 description("Tests that we can compute the bounds of a range of text from th
e accessibility tree."); |
23 | 23 |
24 if (window.accessibilityController) { | 24 if (window.accessibilityController) { |
25 var axParagraph = accessibilityController.accessibleElementById('paragra
ph'); | 25 var axParagraph = accessibilityController.accessibleElementById('paragra
ph'); |
26 var axStaticText = axParagraph.childAtIndex(0); | 26 var axStaticText = axParagraph.childAtIndex(0); |
27 | 27 |
28 // The first characters of stringValue are 'AXValue: ' - use substr to g
et rid of those. | 28 var text = axStaticText.name; |
29 // The accessible text shouldn't have any spaces. | |
30 var text = axStaticText.stringValue.substr(9); | |
31 shouldBe("text.length", "185"); | 29 shouldBe("text.length", "185"); |
32 debug("Accessible text: \"" + text + "\""); | 30 debug("Accessible text: \"" + text + "\""); |
33 | 31 |
34 // Append the text from all of the inline text boxes and make sure we ge
t the same text. | 32 // Append the text from all of the inline text boxes and make sure we ge
t the same text. |
35 var appendedInlineText = ''; | 33 var appendedInlineText = ''; |
36 for (var i = 0; i < axStaticText.childrenCount; i++) { | 34 for (var i = 0; i < axStaticText.childrenCount; i++) { |
37 var axInlineTextBox = axStaticText.childAtIndex(i); | 35 var axInlineTextBox = axStaticText.childAtIndex(i); |
38 appendedInlineText += axInlineTextBox.stringValue.substr(9); | 36 appendedInlineText += axInlineTextBox.name; |
39 } | 37 } |
40 shouldBe("appendedInlineText", "text"); | 38 shouldBe("appendedInlineText", "text"); |
41 | 39 |
42 // For several possible words in the text, get the bounds of the word in
the accessibility | 40 // For several possible words in the text, get the bounds of the word in
the accessibility |
43 // tree, and also in the DOM, and assert that they're the same, within o
ne pixel. | 41 // tree, and also in the DOM, and assert that they're the same, within o
ne pixel. |
44 var paragraph = document.getElementById('paragraph'); | 42 var paragraph = document.getElementById('paragraph'); |
45 var domText = paragraph.innerHTML; | 43 var domText = paragraph.innerHTML; |
46 function testWord(word) { | 44 function testWord(word) { |
47 debug('\nTesting bounds of word: ' + word); | 45 debug('\nTesting bounds of word: ' + word); |
48 | 46 |
(...skipping 16 matching lines...) Expand all Loading... |
65 } | 63 } |
66 testWord('The'); | 64 testWord('The'); |
67 testWord('Hitchhiker'); | 65 testWord('Hitchhiker'); |
68 testWord('Guide'); | 66 testWord('Guide'); |
69 testWord('interstellar'); | 67 testWord('interstellar'); |
70 } | 68 } |
71 </script> | 69 </script> |
72 | 70 |
73 </body> | 71 </body> |
74 </html> | 72 </html> |
OLD | NEW |