haikuwebkit/LayoutTests/accessibility/misspelling-range.html

90 lines
4.1 KiB
HTML
Raw Permalink Normal View History

Expose misspelling ranges for editable content to accessibility clients. https://bugs.webkit.org/show_bug.cgi?id=201752 <rdar://problem/49556828> Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-09-16 Reviewed by Chris Fleizach. Source/WebCore: Test: accessibility/misspelling-range.html Added [WebAccessibilityObjectWrapper misspellingTextMarkerRange] and underlying AccessibilityObject implementation to expose misspellings to accessibility clients that provide an alternative user interface to spell checking. * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::getMisspellingRange const): * accessibility/AccessibilityObject.h: * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: (-[WebAccessibilityObjectWrapper misspellingTextMarkerRange:direction:]): * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (accessibilityMisspellingSearchCriteriaForParameterizedAttribute): (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]): Tools: Test code needed for LayoutTests/accessibility/misspelling-range.html. * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::misspellingTextMarkerRange): (WTR::AccessibilityUIElement::indexForTextMarker): * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::misspellingSearchParameterizedAttributeForCriteria): (WTR::AccessibilityUIElement::misspellingTextMarkerRange): LayoutTests: * accessibility/misspelling-range-expected.txt: Added. * accessibility/misspelling-range.html: Added. * platform/ios-simulator/TestExpectations: Canonical link: https://commits.webkit.org/215447@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-16 09:04:42 +00:00
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
</head>
<body>
<div contenteditable=true id="content" role="textbox">
wrods is misspelled aab lotsi nowadays. euep.
</div>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that misspelling ranges are properly retrieved in the fashion that a spell checker would.");
if (window.accessibilityController) {
var content = document.getElementById("content");
content.focus();
var text = accessibilityController.focusedElement;
var textMarkerRange = text.textMarkerRangeForElement(text);
var startMarker = text.startTextMarkerForTextMarkerRange(textMarkerRange);
debug("textMarkerRange start: " + text.indexForTextMarker(startMarker));
var endMarker = text.endTextMarkerForTextMarkerRange(textMarkerRange);
debug("textMarkerRange end: " + text.indexForTextMarker(endMarker));
// Find the first misspelling, "wrods".
var startRange = text.textMarkerRangeForMarkers(startMarker, startMarker);
startMarker = text.startTextMarkerForTextMarkerRange(startRange);
debug("startRange start: " + text.indexForTextMarker(startMarker));
endMarker = text.endTextMarkerForTextMarkerRange(startRange);
debug("startRange end: " + text.indexForTextMarker(endMarker));
var misspellingRange = text.misspellingTextMarkerRange(startRange, true);
startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling start: " + text.indexForTextMarker(startMarker));
endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling end: " + text.indexForTextMarker(endMarker));
shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'wrods'");
// Find the next one, "aab".
startRange = misspellingRange;
misspellingRange = text.misspellingTextMarkerRange(startRange, true);
startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling start: " + text.indexForTextMarker(startMarker));
endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling end: " + text.indexForTextMarker(endMarker));
shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'aab'");
// Find the next one, "lotsi".
startRange = misspellingRange;
misspellingRange = text.misspellingTextMarkerRange(startRange, true);
startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling start: " + text.indexForTextMarker(startMarker));
endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling end: " + text.indexForTextMarker(endMarker));
shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'lotsi'");
// Find the next one, "euep".
startRange = misspellingRange;
misspellingRange = text.misspellingTextMarkerRange(startRange, true);
startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling start: " + text.indexForTextMarker(startMarker));
endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling end: " + text.indexForTextMarker(endMarker));
shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'euep'");
// Find the previous one, "lotsi".
startRange = misspellingRange;
misspellingRange = text.misspellingTextMarkerRange(startRange, false);
startMarker = text.startTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling start: " + text.indexForTextMarker(startMarker));
endMarker = text.endTextMarkerForTextMarkerRange(misspellingRange);
debug("misspelling end: " + text.indexForTextMarker(endMarker));
shouldBe("text.stringForTextMarkerRange(misspellingRange)", "'lotsi'");
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>