Bug 726364 - "ASSERTION: unexpected disconnected nodes" with range, splitText, mutation event". r=smaug

This commit is contained in:
Mats Palmgren 2012-02-12 22:21:49 +01:00
parent 2155a76fec
commit 0a812d37d3
3 changed files with 52 additions and 0 deletions

View File

@ -752,6 +752,9 @@ nsGenericDOMDataNode::SplitData(PRUint32 aOffset, nsIContent** aReturn,
return rv;
}
nsIDocument* document = GetCurrentDoc();
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, true);
// Use Clone for creating the new node so that the new node is of same class
// as this node!
nsCOMPtr<nsIContent> newContent = CloneDataNode(mNodeInfo, false);

View File

@ -554,6 +554,7 @@ _TEST_FILES2 = \
file_bug717511.html^headers^ \
file_bug717511_2.html \
file_bug717511_2.html^headers^ \
test_bug726364.html \
$(NULL)
_CHROME_FILES = \

View File

@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=726364
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 726364</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=726364">Mozilla Bug 726364</a>
<p id="display"><div id="v">ABC</div></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 726364 **/
function boom()
{
var v = document.getElementById("v");
var t = v.firstChild;
is(v.childNodes.length,1, "child count");
var f = function(event) {
window.removeEventListener("DOMCharacterDataModified", f, true);
is(v.childNodes[0],t, "first child is the same");
is(v.childNodes.length,2, "child count");
r.setEnd(v, 0);
SimpleTest.finish();
};
window.addEventListener("DOMCharacterDataModified", f, true);
var r = document.createRange();
r.setStart(t, 2);
t.splitText(1);
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(boom);
</script>
</pre>
</body>
</html>