52 lines
1.7 KiB
HTML
52 lines
1.7 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../resources/js-test-pre.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="content" contenteditable tabindex="0">helloworld</div>
|
|
|
|
<div id="console"></div>
|
|
|
|
<script>
|
|
if (window.accessibilityController) {
|
|
window.jsTestIsAsync = true;
|
|
|
|
var content = document.getElementById("content");
|
|
content.focus();
|
|
|
|
var text = accessibilityController.focusedElement;
|
|
text.setSelectedTextRange(5, 0);
|
|
shouldBecomeEqual("text.selectedTextRange", "'{5, 0}'", function() {
|
|
// Insert a linebreak between "hello" and "world".
|
|
text.replaceTextInRange("\n", 5, 0);
|
|
|
|
var t = text.stringForRange(0, 11);
|
|
t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
|
|
debug("There must be only one [newline] between hello and world: " + t);
|
|
|
|
text.setSelectedTextRange(6, 0);
|
|
shouldBecomeEqual("text.selectedTextRange", "'{6, 0}'", function() {
|
|
// Insert another linebreak before "world".
|
|
text.replaceTextInRange("\n", 6, 0);
|
|
|
|
var t = text.stringForRange(0, 12);
|
|
t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
|
|
debug("There must be two [newline] between hello and world: " + t);
|
|
|
|
text.setSelectedTextRange(7, 0);
|
|
shouldBecomeEqual("text.selectedTextRange", "'{7, 0}'", function() {
|
|
var t = text.stringForRange(7, 5);
|
|
t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
|
|
debug("The text after the newline should be world: " + t);
|
|
|
|
finishJSTest();
|
|
});
|
|
});
|
|
});
|
|
}
|
|
</script>
|
|
<script src="../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|