Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Correctly report selected text range for accessibility APIs for role=…
…textbox https://bugs.webkit.org/show_bug.cgi?id=65900 Patch by Alice Boxhall <aboxhall@chromium.org> on 2011-08-30 Reviewed by Chris Fleizach. Source/WebCore: Test: accessibility/textbox-role-reports-selection.html * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::indexForVisiblePosition): (WebCore::AccessibilityRenderObject::rootEditableElementForPosition): (WebCore::AccessibilityRenderObject::nodeIsTextControl): (WebCore::AccessibilityRenderObject::determineAriaRoleAttribute): * accessibility/AccessibilityRenderObject.h: LayoutTests: * accessibility/textbox-role-reports-selection-expected.txt: Added. * accessibility/textbox-role-reports-selection.html: Added. Canonical link: https://commits.webkit.org/83059@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@94134 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
74e980b
commit fd51ae143e7b5863f3cbf8eb76c1340a2eab6844
Showing
6 changed files
with
136 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,12 @@ | ||
This tests that the AXSelection property is correctly reported for non-native text boxes. | ||
Some text in a textbox (34 chars). | ||
PASS: axSelection is {0, 0} (Collapsed selection at start) | ||
PASS: axSelection is {34, 0} (Collapsed selection at end) | ||
PASS: axSelection is {15, 0} (Collapsed selection in the middle) | ||
PASS: axSelection is {15, 2} (Non-collapsed selection in the middle) | ||
PASS: axSelection is {0, 15} (Non-collapsed selection at the start) | ||
PASS: axSelection is {15, 19} (Non-collapsed selection at the end) | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,60 @@ | ||
<!DOCTYPE HTML PUBLIC> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../fast/js/resources/js-test-style.css"> | ||
<script> | ||
var successfullyParsed = false; | ||
</script> | ||
<script src="../fast/js/resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
This tests that the AXSelection property is correctly reported for non-native text boxes.<br> | ||
<div role="textbox" id="ariaTextBox" aria-multiline="false" tabindex="0">Some text in a textbox (34 chars).</div> | ||
<div id="console"></div> | ||
<script> | ||
function assertEvaluatesTo(actual, expected, message) { | ||
var actualValue = 0; | ||
try { | ||
actualValue = eval(actual); | ||
} catch (e) { | ||
debug("Evaluating " + actual + ": Threw exception " + e); | ||
return; | ||
} | ||
if (actualValue === expected) | ||
debug("PASS: " + actual + " is " + expected + (message ? " (" + message + ")" : "")); | ||
else | ||
debug("FAIL: " + actual + " should be " + expected + ", got " + actualValue + (message ? " (" + message + ")" : "")); | ||
} | ||
|
||
function assertCorrectAXSelection(element, selection, message) { | ||
element.focus(); | ||
var selectionValues = /\{(\d+), (\d+)\}/.exec(selection); | ||
var selectionStart = eval(selectionValues[1]); | ||
var selectionLength = eval(selectionValues[2]); | ||
var selectionEnd = selectionStart + selectionLength; | ||
|
||
window.getSelection().setBaseAndExtent(element.firstChild, selectionStart, element.firstChild, selectionEnd); | ||
var axElement = accessibilityController.focusedElement; | ||
axSelection = axElement.selectedTextRange; | ||
assertEvaluatesTo("axSelection", selection, message); | ||
} | ||
|
||
if (window.layoutTestController && window.accessibilityController) { | ||
window.layoutTestController.dumpAsText(); | ||
var ariaTextBox = document.getElementById("ariaTextBox"); | ||
var textLength = ariaTextBox.textContent.length; | ||
|
||
assertCorrectAXSelection(ariaTextBox, "{0, 0}", "Collapsed selection at start"); | ||
assertCorrectAXSelection(ariaTextBox, "{" + textLength + ", 0}", "Collapsed selection at end"); | ||
assertCorrectAXSelection(ariaTextBox, "{15, 0}", "Collapsed selection in the middle"); | ||
assertCorrectAXSelection(ariaTextBox, "{15, 2}", "Non-collapsed selection in the middle"); | ||
assertCorrectAXSelection(ariaTextBox, "{0, 15}", "Non-collapsed selection at the start"); | ||
assertCorrectAXSelection(ariaTextBox, "{15, "+ (textLength - 15) + "}", "Non-collapsed selection at the end"); | ||
} | ||
|
||
successfullyParsed = true; | ||
</script> | ||
|
||
<script src="../fast/js/resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters