From 89cfc393d2d9170415dbf70d4273df756b83ea6e Mon Sep 17 00:00:00 2001
From: Boris Zbarsky
Date: Fri, 12 Dec 2008 14:26:07 -0500
Subject: [PATCH] Bug 468210. Do a better job of unhooking our anonymous
content. r+sr=sicking
---
content/xbl/src/nsXBLBinding.cpp | 8 +++++
content/xbl/test/Makefile.in | 1 +
content/xbl/test/test_bug468210.xhtml | 52 +++++++++++++++++++++++++++
3 files changed, 61 insertions(+)
create mode 100644 content/xbl/test/test_bug468210.xhtml
diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp
index 5ac93d2fab4..356dfdc4b17 100644
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -1143,6 +1143,14 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
#endif
nsAutoScriptBlocker scriptBlocker;
+ // Unbind the _kids_ of the anonymous content, not just the anonymous
+ // content itself, since they are bound to some other parent. Basically
+ // we want to undo the mess that InstallAnonymousContent created.
+ PRUint32 childCount = anonymous->GetChildCount();
+ for (PRUint32 i = 0; i < childCount; i++) {
+ anonymous->GetChildAt(i)->UnbindFromTree();
+ }
+
anonymous->UnbindFromTree(); // Kill it.
#ifdef MOZ_XUL
diff --git a/content/xbl/test/Makefile.in b/content/xbl/test/Makefile.in
index 96e34185f87..f2dd3cb4ab3 100644
--- a/content/xbl/test/Makefile.in
+++ b/content/xbl/test/Makefile.in
@@ -66,6 +66,7 @@ _TEST_FILES = \
file_bug379959_data.html \
file_bug379959_cross.html \
file_bug379959_xbl.xml \
+ test_bug468210.xhtml \
$(NULL)
libs:: $(_TEST_FILES)
diff --git a/content/xbl/test/test_bug468210.xhtml b/content/xbl/test/test_bug468210.xhtml
new file mode 100644
index 00000000000..bc6327f9a70
--- /dev/null
+++ b/content/xbl/test/test_bug468210.xhtml
@@ -0,0 +1,52 @@
+
+
+
+ Test for Bug 468210
+
+
+
+
+
+
+
+
+
+
+
+Mozilla Bug 468210
+
+
+
+
+
+
+
+
+
+
+
+