blob: 5d2ec1c10fb6b6a3cf2752d4c98fa7b80094b6b8 [file] [log] [blame]
<p>This tests link deletion. After deleting a link, subsequent text should be inserted into a link.</p>
<div id="div" contenteditable="true">Hello <a id="link" href="http://www.google.com/">b</a> World</div>
<ol id="console"></ol>
<script>
function log(str) {
var li = document.createElement("li");
li.appendChild(document.createTextNode(str));
var console = document.getElementById("console");
console.appendChild(li);
}
function shouldBe(expected, actual) {
if (expected != actual)
log("Failure. Expected: " + expected + ", Actual: " + actual);
else
log("Passed");
}
if (window.layoutTestController)
layoutTestController.dumpEditingCallbacks();
var div = document.getElementById("div");
var sel = window.getSelection();
sel.setPosition(div, 0);
sel.modify("move", "forward", "word");
sel.modify("move", "forward", "word");
sel.modify("extend", "backward", "character");
document.execCommand("Delete");
document.execCommand("InsertText", false, "this text should be in a link");
var link = document.getElementById("link");
if (link)
shouldBe(link.href, "http://www.google.com/");
else
log("Failure, the link wasn't reinserted, or it had a different id.");
</script>