Fix keypad issue when ime context transit to another context
[framework/web/webkit-efl.git] / LayoutTests / accessibility / textbox-role-reports-selection.html
1 <!DOCTYPE HTML PUBLIC>
2 <html>
3 <head>
4 <script src="../fast/js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 This tests that the AXSelection property is correctly reported for non-native text boxes.<br>
8 <div role="textbox" id="ariaTextBox" aria-multiline="false" tabindex="0">Some text 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 ? " (" + message + ")" : ""));
21         else
22             debug("FAIL: " + actual + " should be " + expected + ", got " + actualValue + (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, selectionStart, 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}", "Collapsed selection at end");
45         assertCorrectAXSelection(ariaTextBox, "{15, 0}", "Collapsed selection in the middle");
46         assertCorrectAXSelection(ariaTextBox, "{15, 2}", "Non-collapsed selection in the middle");
47         assertCorrectAXSelection(ariaTextBox, "{0, 15}", "Non-collapsed selection at the start");
48         assertCorrectAXSelection(ariaTextBox, "{15, "+ (textLength - 15) + "}", "Non-collapsed selection at the end");
49     }
50
51 </script>
52
53 <script src="../fast/js/resources/js-test-post.js"></script>
54 </body>
55 </html>