| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 | 4 |
| 5 <p id="p"> | 5 <p id="paragraph"> |
| 6 The <b id="quick">quick</b> brown fox | 6 The <b id="quick">quick</b> brown fox |
| 7 <br> | 7 <br> |
| 8 jumps over the lazy <b id="dog">dog</b>. | 8 jumps over the lazy <b id="dog">dog</b>. |
| 9 </p> | 9 </p> |
| 10 | 10 |
| 11 <div contentEditable="true" id="contentEditable"> |
| 12 <div> |
| 13 <span>Line </span><span>one has one trailing space.</span><span> </span> |
| 14 </div> |
| 15 <div> |
| 16 <span>		</span><span>Line</span><span> two has two leading tabs.</
span> |
| 17 </div> |
| 18 </div> |
| 19 |
| 11 <script> | 20 <script> |
| 12 test(function(t) | 21 test(function(t) |
| 13 { | 22 { |
| 14 var axObj = accessibilityController.accessibleElementById("p"); | 23 var axObj = accessibilityController.accessibleElementById('paragraph'); |
| 24 // Find the first inline text box. |
| 15 while (axObj.childrenCount > 0) | 25 while (axObj.childrenCount > 0) |
| 16 axObj = axObj.childAtIndex(0); | 26 axObj = axObj.childAtIndex(0); |
| 17 assert_equals(axObj.role, "AXRole: AXInlineTextBox"); | 27 assert_equals(axObj.role, 'AXRole: AXInlineTextBox'); |
| 18 | 28 |
| 19 var line = []; | 29 var lineText = []; |
| 20 var lastObj = axObj; | 30 var lastInlineText = axObj; |
| 21 while (axObj && axObj.isValid) { | 31 while (axObj && axObj.isValid) { |
| 22 assert_equals(axObj.role, "AXRole: AXInlineTextBox"); | 32 assert_equals(axObj.role, 'AXRole: AXInlineTextBox'); |
| 23 line.push(axObj.stringValue.replace("AXValue: ", "")); | 33 lineText.push(axObj.name.replace('AXValue: ', '')); |
| 24 lastObj = axObj; | 34 lastInlineText = axObj; |
| 25 axObj = axObj.nextOnLine(); | 35 axObj = axObj.nextOnLine(); |
| 26 } | 36 } |
| 27 | 37 assert_array_equals(lineText, ['The ', 'quick', ' brown fox ', '\n']); |
| 28 assert_equals(JSON.stringify(line), JSON.stringify(["The ","quick"," brown f
ox ","\n"])); | |
| 29 | 38 |
| 30 // Now walk backwards. | 39 // Now walk backwards. |
| 31 var line2 = []; | 40 lineText = []; |
| 32 axObj = lastObj; | 41 axObj = lastInlineText; |
| 33 while (axObj && axObj.isValid) { | 42 while (axObj && axObj.isValid) { |
| 34 assert_equals(axObj.role, "AXRole: AXInlineTextBox"); | 43 assert_equals(axObj.role, 'AXRole: AXInlineTextBox'); |
| 35 line2.unshift(axObj.stringValue.replace("AXValue: ", "")); | 44 lineText.unshift(axObj.name.replace('AXValue: ', '')); |
| 36 axObj = axObj.previousOnLine(); | 45 axObj = axObj.previousOnLine(); |
| 37 } | 46 } |
| 47 assert_array_equals(lineText, ['The ', 'quick', ' brown fox ', '\n']); |
| 48 }, 'Test |nextOnLine| and |previousOnLine| for |AXInlineTextBox|.'); |
| 38 | 49 |
| 39 assert_equals(JSON.stringify(line2), JSON.stringify(["The ","quick"," brown
fox ","\n"])); | 50 test(function(t) |
| 40 }, "Walk the inline text boxes on a line of text."); | 51 { |
| 52 var axEditable = accessibilityController.accessibleElementById('contentEdita
ble'); |
| 53 // There should be two lines in this content editable. |
| 54 assert_equals(axEditable.childrenCount, 2); |
| 55 var lines = [axEditable.childAtIndex(0), axEditable.childAtIndex(1)]; |
| 56 var lineText = [ |
| 57 ['Line ', 'one has one trailing space.'], |
| 58 ['Line', ' two has two leading tabs.']]; |
| 41 | 59 |
| 42 if (window.testRunner) | 60 for (var i = 0; i < lines.length; ++i) { |
| 43 document.getElementById('p').style.display = 'none'; | 61 var currentLine = lines[i]; |
| 62 assert_equals(currentLine.nextOnLine(), undefined); |
| 63 assert_equals(currentLine.previousOnLine(), undefined); |
| 64 } |
| 65 |
| 66 for (var i = 0; i < lines.length; ++i) { |
| 67 var currentLine = lines[i]; |
| 68 var currentLineText = lineText[i]; |
| 69 // There should be two spans per line since white space is removed. |
| 70 assert_equals(currentLine.childrenCount, 2); |
| 71 |
| 72 var span1 = currentLine.childAtIndex(0); |
| 73 var span2 = currentLine.childAtIndex(1); |
| 74 var inlineText1 = span1.childAtIndex(0); |
| 75 var inlineText2 = span2.childAtIndex(0); |
| 76 var spanText1 = currentLineText[0]; |
| 77 var spanText2 = currentLineText[1]; |
| 78 assert_equals(span1.role, 'AXRole: AXStaticText'); |
| 79 assert_equals(span2.role, 'AXRole: AXStaticText'); |
| 80 assert_equals(span1.name, spanText1); |
| 81 assert_equals(span2.name, spanText2); |
| 82 |
| 83 // |next/previousOnLine| APIs jump directly to the inline text boxes |
| 84 // skipping the parent span element. |
| 85 assert_equals(span1.nextOnLine(), inlineText2, 'span1 -> inlineText2'); |
| 86 assert_equals(inlineText1.nextOnLine(), inlineText2, 'inlineText1 -> inl
ineText2'); |
| 87 assert_equals(span2.previousOnLine(), inlineText1, 'span2 -> inlineText1
'); |
| 88 assert_equals(inlineText2.previousOnLine(), inlineText1, 'inlineText2 ->
inlineText1'); |
| 89 } |
| 90 }, 'Test |nextOnLine| and |previousOnLine| for |AXLayoutObject|.'); |
| 91 |
| 92 if (window.testRunner) { |
| 93 document.getElementById('paragraph').style.display = 'none'; |
| 94 document.getElementById('contentEditable').style.display = 'none'; |
| 95 } |
| 44 </script> | 96 </script> |
| OLD | NEW |