blob: beaf8f1842902dbb9988d0d6b1dcfa81dbe965cc [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<textarea id="textarea">abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789</textarea>
<br>
<div contenteditable="true" id="contenteditable">abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789</div>
<br>
<script>
description("Test for lineIndexForTextMarker in editable text elements. The text contains soft and hard linebreaks.");
function logLineIndexesForElement(elementID) {
debug(`${elementID}:`);
var p = accessibilityController.accessibleElementById(elementID).children[0];
var range = p.textMarkerRangeForElement(p);
var length = p.textMarkerRangeLength(range);
var current = p.startTextMarkerForTextMarkerRange(range);
for (let i = 0; i < length; ++i) {
let character = p.stringForTextMarkerRange(p.textMarkerRangeForMarkers(current, p.nextTextMarker(current)));
debug(`${i} ${character} ${p.lineIndexForTextMarker(current)}`);
current = p.nextTextMarker(current);
}
}
if (window.accessibilityController) {
logLineIndexesForElement("textarea");
logLineIndexesForElement("contenteditable");
}
</script>
</body>
</html>