blob: 279f6b995714c10f9fe70399e7da39319b77e580 [file] [log] [blame]
<!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>