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="horizontalParagraph"> |
| 10 one two אחתשתיים three four שלושהארבעה |
| 11 </p> |
| 12 |
| 13 <p id="verticalParagraph" style="-webkit-writing-mode: vertical-lr"> |
| 14 one two אחתשתיים three four שלושהארבעה |
| 15 </p> |
| 16 |
| 17 <p id="description"></p> |
| 18 |
| 19 <div id="console"></div> |
| 20 |
| 21 <script> |
| 22 |
| 23 description("Tests that we can compute the bounds of a range of text from th
e accessibility tree in bidirectional text."); |
| 24 |
| 25 if (window.accessibilityController) { |
| 26 // For several possible words in the text, get the bounds of the word in
the accessibility |
| 27 // tree, and also in the DOM, and assert that they're exactly the same. |
| 28 function testWord(elementId, word) { |
| 29 debug('\nTesting bounds of word ' + word + ' in ' + elementId); |
| 30 |
| 31 var paragraph = document.getElementById(elementId); |
| 32 var domText = paragraph.innerHTML; |
| 33 |
| 34 // Get the bounds from the accessibility tree. |
| 35 var axParagraph = accessibilityController.accessibleElementById(elem
entId); |
| 36 var axStaticText = axParagraph.childAtIndex(0); |
| 37 var text = axStaticText.stringValue.substr(9); |
| 38 var wordAxIndex = text.indexOf(word); |
| 39 eval('window.axBounds = ' + axStaticText.boundsForRange(wordAxIndex,
wordAxIndex + word.length) + ';'); |
| 40 |
| 41 // Get the bounds from the DOM. |
| 42 var domIndex = domText.indexOf(word); |
| 43 var range = new Range(); |
| 44 range.setStart(paragraph.firstChild, domIndex); |
| 45 range.setEnd(paragraph.firstChild, domIndex + word.length); |
| 46 window.rangeBounds = range.getBoundingClientRect(); |
| 47 |
| 48 // Make sure they're the same. |
| 49 shouldBeCloseTo("axBounds.x", rangeBounds.left, 2); |
| 50 shouldBeCloseTo("axBounds.y", rangeBounds.top, 2); |
| 51 shouldBeCloseTo("axBounds.width", rangeBounds.width, 2); |
| 52 shouldBeCloseTo("axBounds.height", rangeBounds.height, 2); |
| 53 } |
| 54 |
| 55 testWord('horizontalParagraph', 'one'); |
| 56 testWord('horizontalParagraph', 'two'); |
| 57 testWord('horizontalParagraph', 'three'); |
| 58 testWord('horizontalParagraph', 'four'); |
| 59 testWord('horizontalParagraph', 'אחתשתיים'); |
| 60 testWord('horizontalParagraph', 'שלושהארבעה'); |
| 61 |
| 62 testWord('verticalParagraph', 'one'); |
| 63 testWord('verticalParagraph', 'two'); |
| 64 testWord('verticalParagraph', 'three'); |
| 65 testWord('verticalParagraph', 'four'); |
| 66 testWord('verticalParagraph', 'אחתשתיים'); |
| 67 testWord('verticalParagraph', 'שלושהארבעה'); |
| 68 } |
| 69 </script> |
| 70 |
| 71 <script src="../fast/js/resources/js-test-post.js"></script> |
| 72 </body> |
| 73 </html> |
OLD | NEW |