Bug 614058. Fix regression in IsEqualNode. r=jst, a=blocker
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 30 Nov 2010 13:19:59 -0500
changeset 58388 2af96a164c62c566cc57d05ff4b558320efe9387
parent 58387 2eeaa6c8d0a37c0b1d4bad2c7423e45bbd55ce25
child 58390 877b580f1bdbae2b86c546b9bfd41b65a82192fd
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersjst, blocker
bugs614058
milestone2.0b8pre
Bug 614058. Fix regression in IsEqualNode. r=jst, a=blocker
content/base/src/nsGenericElement.cpp
content/base/test/Makefile.in
content/base/test/test_bug614058.html
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -1090,41 +1090,40 @@ nsIContent::IsEqual(nsIContent* aOther)
 
       if (!element2->AttrValueIs(attrName1->NamespaceID(),
                                  attrName1->LocalName(),
                                  string1,
                                  eCaseMatters)) {
         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);
     nsCOMPtr<nsIDOMNode> domNode2 = do_QueryInterface(aOther);
     NS_ASSERTION(domNode1 && domNode2, "How'd we get nsIContent without nsIDOMNode?");
     domNode1->GetNodeValue(string1);
     domNode2->GetNodeValue(string2);
     if (!string1.Equals(string2)) {
       return PR_FALSE;
     }
   }
 
+  // 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;
 }
 
 PRBool
 nsIContent::IsEqualNode(nsINode* aOther)
 {
   if (!aOther || !aOther->IsNodeOfType(eCONTENT))
     return PR_FALSE;
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -365,27 +365,27 @@ include $(topsrcdir)/config/rules.mk
 		test_bug503481b.html \
 		file_bug503481b_inner.html \
 		test_viewport_scroll.html \
 		test_CSP.html \
 		file_CSP.sjs \
 		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 \
 		test_bug545644.html \
 		test_bug545644.xhtml \
 		test_bug553896.xhtml \
 		test_bug515401.html \
 		test_bug541937.html \
@@ -439,16 +439,17 @@ include $(topsrcdir)/config/rules.mk
 		file_bug604660-2.xsl \
 		file_bug604660-3.js \
 		file_bug604660-4.js \
 		file_bug604660-5.xml \
 		file_bug604660-6.xsl \
 		test_bug605982.html \
 		test_bug606729.html \
 		test_treewalker_nextsibling.xml \
+		test_bug614058.html \
 		$(NULL)
 
 # This test fails on the Mac for some reason
 ifneq (,$(filter gtk2 windows,$(MOZ_WIDGET_TOOLKIT)))
 _TEST_FILES2 += 	test_copyimage.html \
 		$(NULL)
 endif
 
new file mode 100644
--- /dev/null
+++ b/content/base/test/test_bug614058.html
@@ -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>