| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 <!DOCTYPE HTML PUBLIC> |  | 
| 2 <html> |  | 
| 3 <head> |  | 
| 4 <script src="../resources/js-test.js"></script> |  | 
| 5 </head> |  | 
| 6 <body> |  | 
| 7 This tests that the AXSelection property is correctly reported for non-native te
    xt boxes.<br> |  | 
| 8 <div role="textbox" id="ariaTextBox" aria-multiline="false" tabindex="0">Some te
    xt in a textbox (34 chars).</div> |  | 
| 9 <div id="console"></div> |  | 
| 10 <script> |  | 
| 11     function assertEvaluatesTo(actual, expected, message) { |  | 
| 12         var actualValue = 0; |  | 
| 13         try { |  | 
| 14             actualValue = eval(actual); |  | 
| 15         } catch (e) { |  | 
| 16             debug("Evaluating " + actual + ": Threw exception " + e); |  | 
| 17             return; |  | 
| 18         } |  | 
| 19         if (actualValue === expected) |  | 
| 20             debug("PASS: " + actual + " is " + expected + (message ? " (" + mess
    age + ")" : "")); |  | 
| 21         else |  | 
| 22             debug("FAIL: " + actual + " should be " + expected + ", got " + actu
    alValue + (message ? " (" + message + ")" : "")); |  | 
| 23     } |  | 
| 24 |  | 
| 25     function assertCorrectAXSelection(element, selection, message) { |  | 
| 26         element.focus(); |  | 
| 27         var selectionValues = /\{(\d+), (\d+)\}/.exec(selection); |  | 
| 28         var selectionStart = eval(selectionValues[1]); |  | 
| 29         var selectionLength = eval(selectionValues[2]); |  | 
| 30         var selectionEnd = selectionStart + selectionLength; |  | 
| 31 |  | 
| 32         window.getSelection().setBaseAndExtent(element.firstChild, selectionStar
    t, element.firstChild, selectionEnd); |  | 
| 33         var axElement = accessibilityController.focusedElement; |  | 
| 34         axSelection = axElement.selectedTextRange; |  | 
| 35         assertEvaluatesTo("axSelection", selection, message); |  | 
| 36     } |  | 
| 37 |  | 
| 38     if (window.testRunner && window.accessibilityController) { |  | 
| 39         window.testRunner.dumpAsText(); |  | 
| 40         var ariaTextBox = document.getElementById("ariaTextBox"); |  | 
| 41         var textLength = ariaTextBox.textContent.length; |  | 
| 42 |  | 
| 43         assertCorrectAXSelection(ariaTextBox, "{0, 0}", "Collapsed selection at 
    start"); |  | 
| 44         assertCorrectAXSelection(ariaTextBox, "{" + textLength + ", 0}", "Collap
    sed selection at end"); |  | 
| 45         assertCorrectAXSelection(ariaTextBox, "{15, 0}", "Collapsed selection in
     the middle"); |  | 
| 46         assertCorrectAXSelection(ariaTextBox, "{15, 2}", "Non-collapsed selectio
    n in the middle"); |  | 
| 47         assertCorrectAXSelection(ariaTextBox, "{0, 15}", "Non-collapsed selectio
    n at the start"); |  | 
| 48         assertCorrectAXSelection(ariaTextBox, "{15, "+ (textLength - 15) + "}", 
    "Non-collapsed selection at the end"); |  | 
| 49     } |  | 
| 50 |  | 
| 51 </script> |  | 
| 52 |  | 
| 53 </body> |  | 
| 54 </html> |  | 
| OLD | NEW | 
|---|