blob: 71da71c81451243db2eab501160f1936c3df8705 [file] [log] [blame]
<html>
<head>
<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function getStringForNode(node) {
return node + "(" + node.data + ")";
}
function editingTest() {
var start = document.getElementById("start");
var x = start.offsetLeft + 5;
var middleY = start.offsetTop + start.offsetHeight / 2;
var endX = document.getElementById("end").offsetLeft;
eventSender.mouseMoveTo(x, middleY);
eventSender.mouseDown();
eventSender.mouseUp();
eventSender.mouseDown();
eventSender.mouseMoveTo(endX, middleY);
eventSender.mouseUp();
document.execCommand("Delete");
document.execCommand("Undo");
var selection = window.getSelection();
if (selection.anchorNode != start.nextSibling ||
selection.anchorOffset != 1 ||
selection.focusNode != document.getElementById("root").firstChild ||
selection.focusOffset != 4) {
document.getElementById("result").innerHTML = "FAILED. Selection was " +
"anchorNode:" + getStringForNode(selection.anchorNode) +
" anchorOffset:" + selection.anchorOffset +
" focusNode:" + getStringForNode(selection.focusNode) +
" focusOffset:" + selection.focusOffset;
} else
document.getElementById("result").innerHTML = "PASSED";
}
</script>
</head>
<body>
<div class="explanation">
<div class="scenario">
Tests:
<br>
Double-click the green "a" and drag backwards to select "bar baz" with word granularity. Delete, then undo the delete. The space that got smart deleted should now be selected and the anchor of the selection should be at the end of the selection.
</div>
</div>
<br>
<div contenteditable id="root">
foo b<span id="end">a</span>r b<span id="start" style="color:green">a</span>z biz
</div>
<div id="result"></div>
<script>
testRunner.waitUntilDone();
setTimeout(function() {
editingTest();
testRunner.notifyDone();
}, 1000);
</script>
</body>
</html>