MediaPlayerPrivateAVFoundationObjC's "periodic time observer" is unnecessary
[WebKit-https.git] / LayoutTests / accessibility / textbox-role-reports-selection.html
1 <!DOCTYPE HTML PUBLIC>
2 <html>
3 <head>
4 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
5 <script>
6 var successfullyParsed = false;
7 </script>
8 <script src="../fast/js/resources/js-test-pre.js"></script>
9 </head>
10 <body>
11 This tests that the AXSelection property is correctly reported for non-native text boxes.<br>
12 <div role="textbox" id="ariaTextBox" aria-multiline="false" tabindex="0">Some text in a textbox (34 chars).</div>
13 <div id="console"></div>
14 <script>
15     function assertEvaluatesTo(actual, expected, message) {
16         var actualValue = 0;
17         try {
18             actualValue = eval(actual);
19         } catch (e) {
20             debug("Evaluating " + actual + ": Threw exception " + e);
21             return;
22         }
23         if (actualValue === expected)
24             debug("PASS: " + actual + " is " + expected + (message ? " (" + message + ")" : ""));
25         else
26             debug("FAIL: " + actual + " should be " + expected + ", got " + actualValue + (message ? " (" + message + ")" : ""));
27     }
28
29     function assertCorrectAXSelection(element, selection, message) {
30         element.focus();
31         var selectionValues = /\{(\d+), (\d+)\}/.exec(selection);
32         var selectionStart = eval(selectionValues[1]);
33         var selectionLength = eval(selectionValues[2]);
34         var selectionEnd = selectionStart + selectionLength;
35
36         window.getSelection().setBaseAndExtent(element.firstChild, selectionStart, element.firstChild, selectionEnd);
37         var axElement = accessibilityController.focusedElement;
38         axSelection = axElement.selectedTextRange;
39         assertEvaluatesTo("axSelection", selection, message);
40     }
41
42     if (window.layoutTestController && window.accessibilityController) {
43         window.layoutTestController.dumpAsText();
44         var ariaTextBox = document.getElementById("ariaTextBox");
45         var textLength = ariaTextBox.textContent.length;
46
47         assertCorrectAXSelection(ariaTextBox, "{0, 0}", "Collapsed selection at start");
48         assertCorrectAXSelection(ariaTextBox, "{" + textLength + ", 0}", "Collapsed selection at end");
49         assertCorrectAXSelection(ariaTextBox, "{15, 0}", "Collapsed selection in the middle");
50         assertCorrectAXSelection(ariaTextBox, "{15, 2}", "Non-collapsed selection in the middle");
51         assertCorrectAXSelection(ariaTextBox, "{0, 15}", "Non-collapsed selection at the start");
52         assertCorrectAXSelection(ariaTextBox, "{15, "+ (textLength - 15) + "}", "Non-collapsed selection at the end");
53     }
54
55     successfullyParsed = true;
56 </script>
57
58 <script src="../fast/js/resources/js-test-post.js"></script>
59 </body>
60 </html>