Bug 775972 - crash in nsGenericElement::BindToTree, r=bz
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Sat, 21 Jul 2012 00:55:19 +0300
changeset 99914 6dae57cd2f853430195f7007de21490a008c19f4
parent 99913 d74c21aebfb606390f7916928fc103886b72363b
child 99915 f91c1b55b396e8dd359878059bb51d84b80ad822
push id23155
push useropettay@mozilla.com
push dateFri, 20 Jul 2012 21:56:50 +0000
treeherdermozilla-central@6dae57cd2f85 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs775972
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 775972 - crash in nsGenericElement::BindToTree, r=bz
content/xul/content/src/nsXULElement.cpp
content/xul/content/test/Makefile.in
content/xul/content/test/test_bug775972.xul
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -372,17 +372,18 @@ nsXULElement::Clone(nsINodeInfo *aNodeIn
            rv = element->mAttrsAndChildren.SetAndTakeAttr(originalName->Atom(),
                                                           attrValue);
         } else {
             rv = element->mAttrsAndChildren.SetAndTakeAttr(originalName->NodeInfo(),
                                                            attrValue);
         }
         NS_ENSURE_SUCCESS(rv, rv);
         element->AddListenerFor(*originalName, true);
-        if (originalName->Equals(nsGkAtoms::id)) {
+        if (originalName->Equals(nsGkAtoms::id) &&
+            !originalValue->IsEmptyString()) {
             element->SetHasID();
         }
         if (originalName->Equals(nsGkAtoms::_class)) {
             element->SetFlags(NODE_MAY_HAVE_CLASS);
         }
         if (originalName->Equals(nsGkAtoms::style)) {
             element->SetMayHaveStyle();
         }
--- a/content/xul/content/test/Makefile.in
+++ b/content/xul/content/test/Makefile.in
@@ -15,11 +15,12 @@ MOCHITEST_FILES = 	\
 		test_bug486990.xul \
 		test_bug749367.xul \
 		$(NULL)
 
 MOCHITEST_CHROME_FILES = \
 		test_bug233643.xul \
 		test_bug398289.html \
 		398289-resource.xul \
+		test_bug775972.xul \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/content/xul/content/test/test_bug775972.xul
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=775972
+-->
+<window title="Mozilla Bug 775972"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        onload="test()">
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=775972"
+     target="_blank">Mozilla Bug 775972</a>
+  </body>
+
+  <hbox id="container"><label value="test" id=""/></hbox>
+  <!-- test code goes here -->
+  <script type="application/javascript">
+  <![CDATA[
+
+  /** Test for Bug 775972 **/
+
+  function test() {
+    var c = document.getElementById("container");
+    var clone = c.cloneNode(true);
+    document.documentElement.appendChild(clone);
+    ok(true, "This shouldn't crash!");
+  }
+
+
+  ]]>
+  </script>
+</window>