blob: 8ccc5018d0ad61687f2b265108d490daaa99b7cb [file] [edit]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div id="container">
<div id="text" style="width:200px;" contenteditable="true">Lorem ipsum vivamus nibh urna mollis at aliquam taciti, etiam arcu mi semper nostra taciti nulla dolor</div>
</div>
<script>
let output = "This tests that CharacterOffset that comes from an upstream VisiblePosition is correct.\n\n";
if (window.accessibilityController) {
let text = accessibilityController.accessibleElementById("text").childAtIndex(0);
let textRange = text.textMarkerRangeForElement(text);
let start = text.startTextMarkerForTextMarkerRange(textRange);
let firstLine = text.lineTextMarkerRangeForTextMarker(start);
let firstEnd = text.endTextMarkerForTextMarkerRange(firstLine);
output += `First Line: ${text.stringForTextMarkerRange(firstLine)}\n`;
let next = text.nextTextMarker(firstEnd);
let secondLine = text.lineTextMarkerRangeForTextMarker(next);
let secondStart = text.startTextMarkerForTextMarkerRange(secondLine);
output += `Second Line: ${text.stringForTextMarkerRange(secondLine)}\n`;
// Here firstEnd should contain a upstream position.
// We need to make sure firstEnd does not equal to secondStart after
// converting to CharacterOffset.
let markerRange = text.textMarkerRangeForMarkers(firstEnd, secondStart);
output += `[firstEnd, secondStart]: ${text.stringForTextMarkerRange(markerRange).replace(' ', "'space'")}\n`;
debug(output);
}
</script>
</body>
</html>