blob: 8239a943e270fe1c007ed4296ff7b9e1e2c23148 [file] [log] [blame]
<body contentEditable="true">
<p>When inserting a new line, we should break out of nested divs.</p>
<p id="results"><p>
<div>first<div>second</div><div>third</div></div>
</body>
<script src="../editing.js"></script>
<script>
if (window.testRunner)
window.testRunner.dumpAsText();
if (window.internals)
internals.settings.setEditingBehavior("mac");
function fail(msg) {
document.getElementById("results").innerText = "FAIL";
throw msg;
}
// Try inserting a new line after the last div.
var div2 = document.getElementsByTagName("div")[1];
var div3 = document.getElementsByTagName("div")[2];
execSetSelectionCommand(div3, 0, div3, 0);
execMoveSelectionForwardByWordCommand();
execTypeCharacterCommand("\n");
execInsertHTMLCommand("This should be in a single div.");
var div4 = document.getElementsByTagName("div")[3];
if (div4.innerHTML != "This should be in a single div.")
fail("wrong div4? " + div4.innerHTML);
if (div4.parentNode.tagName != "BODY")
fail("div should not be nested: " + div4.parentNode.tagName);
// Try inserting a new line after the second div. This should be nested.
execSetSelectionCommand(div2, 0, div2, 0);
execMoveSelectionForwardByWordCommand();
execTypeCharacterCommand("\n");
execInsertHTMLCommand("This should be in nested divs.");
var nestedDiv = document.getElementsByTagName("div")[2];
if (nestedDiv.innerHTML != "This should be in nested divs.")
fail("wrong nestedDiv? " + nestedDiv.innerHTML);
if (nestedDiv.parentNode.tagName != "DIV")
fail("div should be nested: " + nestedDiv.parentNode.tagName);
document.getElementById("results").innerText = "SUCCESS";
</script>