blob: e844d2bc9cf37dd4fe63fea9a4ff435b23bead9d [file] [edit]
<!DOCTYPE HTML><!-- webkit-test-runner [ runSingly=true AccessibilityThreadTextApisEnabled=true ] -->
<!-- Copy of content-editable-attributed-string.html. Remove after accessibilityThreadTextApisEnabled is enabled by default. -->
<html>
<head>
<script src="../../resources/accessibility-helper.js"></script>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div contenteditable id="editable">First line.<br>Some text <a href="#">click me</a> <span>more</span> text.<br><i>Another line.</i></div>
<script>
// FIXME: Every stringForTextMarkerRange call should be attributedStringForTextMarkerRange, but we haven't implemented that yet with AccessibilityThreadTextApisEnabled.
if (accessibilityController) {
let output = "Tests that AttributedStrings are retrieved properly from line ranges within a contenteditable with children.\n\n";
let text = accessibilityController.accessibleElementById("editable");
let range = text.textMarkerRangeForElement(text);
let string = text.stringForTextMarkerRange(range);
output += `All text in the contenteditable: "${string}"\n`;
// Get the range for the first line.
let start = text.startTextMarkerForTextMarkerRange(range);
range = text.lineTextMarkerRangeForTextMarker(start);
string = text.stringForTextMarkerRange(range);
output += `First line: "${string}"\n`;
// Get the range for the second line:
let end = text.nextLineEndTextMarkerForTextMarker(start);
end = text.nextTextMarker(end);
end = text.nextTextMarker(end);
range = text.lineTextMarkerRangeForTextMarker(end);
string = text.stringForTextMarkerRange(range);
output += `Second line: "${string}"\n`;
// Get the range for the third line:
end = text.nextLineEndTextMarkerForTextMarker(end);
end = text.nextTextMarker(end);
end = text.nextTextMarker(end);
range = text.lineTextMarkerRangeForTextMarker(end);
string = text.stringForTextMarkerRange(range);
output += `third line: "${string}"\n`;
debug(output);
}
</script>
</body>
</html>