OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <script src="../fast/js/resources/js-test-pre.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 |
| 9 <p id="paragraph" dir="ltr"> |
| 10 מילה word אחרת another ועוד yet אחת |
| 11 </p> |
| 12 |
| 13 <p id="description"></p> |
| 14 |
| 15 <div id="console"></div> |
| 16 |
| 17 <script> |
| 18 |
| 19 description("Tests that we can compute the bounds of a range of text from th
e accessibility tree in bidirectional text."); |
| 20 |
| 21 if (window.accessibilityController) { |
| 22 var axParagraph = accessibilityController.accessibleElementById('paragra
ph'); |
| 23 var axStaticText = axParagraph.childAtIndex(0); |
| 24 var text = axStaticText.stringValue.substr(9); |
| 25 |
| 26 debug('Accessible text: "' + text + '"'); |
| 27 |
| 28 // For several possible words in the text, get the bounds of the word in
the accessibility |
| 29 // tree, and also in the DOM, and assert that they're exactly the same. |
| 30 var paragraph = document.getElementById('paragraph'); |
| 31 var domText = paragraph.innerHTML; |
| 32 function testWord(word) { |
| 33 debug('\nTesting bounds of word: ' + word); |
| 34 |
| 35 // Get the bounds from the accessibility tree. |
| 36 window.wordAxIndex = text.indexOf(word); |
| 37 eval('window.axBounds = ' + axStaticText.boundsForRange(wordAxIndex,
wordAxIndex + word.length) + ';'); |
| 38 |
| 39 // Get the bounds from the DOM. |
| 40 window.domIndex = domText.indexOf(word); |
| 41 var range = new Range(); |
| 42 range.setStart(paragraph.firstChild, domIndex); |
| 43 range.setEnd(paragraph.firstChild, domIndex + word.length); |
| 44 window.rangeBounds = range.getBoundingClientRect(); |
| 45 |
| 46 // Make sure they're the same. |
| 47 shouldBeCloseTo("axBounds.x", rangeBounds.left, 1); |
| 48 shouldBeCloseTo("axBounds.y", rangeBounds.top, 1); |
| 49 shouldBeCloseTo("axBounds.width", rangeBounds.width, 1); |
| 50 shouldBeCloseTo("axBounds.height", rangeBounds.height, 1); |
| 51 } |
| 52 testWord('yet'); |
| 53 testWord('another'); |
| 54 testWord('word'); |
| 55 testWord('מילה'); |
| 56 testWord('אחרת'); |
| 57 } |
| 58 </script> |
| 59 |
| 60 <xscript src="../fast/js/resources/js-test-post.js"></xscript> |
| 61 </body> |
| 62 </html> |
OLD | NEW |