From 0485d191eb58673f2a8d9b2fc95a17c31e12201c Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 3 Dec 2008 12:25:21 +0200 Subject: [PATCH] Bug 465767 - document.adoptNode() stops working if node was previously adopted in another document, r+sr=bz --- content/base/src/nsNodeUtils.cpp | 11 +++--- content/base/test/Makefile.in | 1 + content/base/test/test_bug465767.html | 50 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 content/base/test/test_bug465767.html diff --git a/content/base/src/nsNodeUtils.cpp b/content/base/src/nsNodeUtils.cpp index 6325a3ac5cbd..8ab1e6dc1867 100755 --- a/content/base/src/nsNodeUtils.cpp +++ b/content/base/src/nsNodeUtils.cpp @@ -520,14 +520,15 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep, // Don't allow importing/adopting nodes from non-privileged "scriptable" // documents to "non-scriptable" documents. nsIDocument* newDoc = nodeInfoManager->GetDocument(); - nsIDocument* currentDoc = aNode->GetOwnerDoc(); - NS_ENSURE_STATE(newDoc && currentDoc); + NS_ENSURE_STATE(newDoc); PRBool hasHadScriptHandlingObject = PR_FALSE; if (!newDoc->GetScriptHandlingObject(hasHadScriptHandlingObject) && !hasHadScriptHandlingObject) { - NS_ENSURE_STATE(nsContentUtils::IsChromeDoc(currentDoc) || - (!currentDoc->GetScriptHandlingObject(hasHadScriptHandlingObject) && - !hasHadScriptHandlingObject)); + nsIDocument* currentDoc = aNode->GetOwnerDoc(); + NS_ENSURE_STATE(currentDoc && + (nsContentUtils::IsChromeDoc(currentDoc) || + (!currentDoc->GetScriptHandlingObject(hasHadScriptHandlingObject) && + !hasHadScriptHandlingObject))); } newNodeInfo = nodeInfoManager->GetNodeInfo(nodeInfo->NameAtom(), diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index a7a64f12649d..50c601f3aa06 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -262,6 +262,7 @@ _TEST_FILES = test_bug5141.html \ bug461735-post-redirect.js \ test_bug461735.html \ test_bug380418.html \ + test_bug465767.html \ test_bug380418.html^headers^ \ test_elementTraversal.html \ test_w3element_traversal.html \ diff --git a/content/base/test/test_bug465767.html b/content/base/test/test_bug465767.html new file mode 100644 index 000000000000..2ae91ff79143 --- /dev/null +++ b/content/base/test/test_bug465767.html @@ -0,0 +1,50 @@ + + + + + Test for Bug 465767 + + + + + +Mozilla Bug 465767 +

+ +
+
+
+ +