Bug 614058. Fix regression in IsEqualNode. r=jst, a=blocker

This commit is contained in:
Boris Zbarsky 2010-11-30 13:19:59 -05:00
parent a1461e82de
commit 23c2b599dc
3 changed files with 54 additions and 24 deletions

View File

@ -1095,19 +1095,6 @@ nsIContent::IsEqual(nsIContent* aOther)
return PR_FALSE;
}
}
// Child nodes count.
PRUint32 childCount = GetChildCount();
if (childCount != element2->GetChildCount()) {
return PR_FALSE;
}
// Iterate over child nodes.
for (PRUint32 i = 0; i < childCount; ++i) {
if (!GetChildAt(i)->IsEqual(element2->GetChildAt(i))) {
return PR_FALSE;
}
}
} else {
// Node value check.
nsCOMPtr<nsIDOMNode> domNode1 = do_QueryInterface(this);
@ -1120,6 +1107,18 @@ nsIContent::IsEqual(nsIContent* aOther)
}
}
// Child nodes count.
PRUint32 childCount = GetChildCount();
if (childCount != aOther->GetChildCount()) {
return PR_FALSE;
}
// Iterate over child nodes.
for (PRUint32 i = 0; i < childCount; ++i) {
if (!GetChildAt(i)->IsEqual(aOther->GetChildAt(i))) {
return PR_FALSE;
}
}
return PR_TRUE;
}

View File

@ -370,17 +370,17 @@ _TEST_FILES2 = \
file_CSP_main.html \
file_CSP_main.html^headers^ \
file_CSP_main.js \
test_CSP_frameancestors.html \
file_CSP_frameancestors.sjs \
file_CSP_frameancestors_main.html \
file_CSP_frameancestors_main.js \
test_CSP_inlinescript.html \
file_CSP_inlinescript_main.html \
file_CSP_inlinescript_main.html^headers^ \
test_CSP_evalscript.html \
file_CSP_evalscript_main.html \
file_CSP_evalscript_main.html^headers^ \
file_CSP_evalscript_main.js \
test_CSP_frameancestors.html \
file_CSP_frameancestors.sjs \
file_CSP_frameancestors_main.html \
file_CSP_frameancestors_main.js \
test_CSP_inlinescript.html \
file_CSP_inlinescript_main.html \
file_CSP_inlinescript_main.html^headers^ \
test_CSP_evalscript.html \
file_CSP_evalscript_main.html \
file_CSP_evalscript_main.html^headers^ \
file_CSP_evalscript_main.js \
test_bug540854.html \
bug540854.sjs \
test_bug548463.html \
@ -444,6 +444,7 @@ _TEST_FILES2 = \
test_bug605982.html \
test_bug606729.html \
test_treewalker_nextsibling.xml \
test_bug614058.html \
$(NULL)
# This test fails on the Mac for some reason

View File

@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=614058
-->
<head>
<title>Test for Bug 614058</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<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=614058">Mozilla Bug 614058</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 614058 **/
var f1 = document.createDocumentFragment();
f2 = f1.cloneNode(true);
f1.appendChild(document.createElement("foo"));
is(f1.isEqualNode(f2), false, "Fragments have different kids!");
</script>
</pre>
</body>
</html>