mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 465767 - document.adoptNode() stops working if node was previously adopted in another document, r+sr=bz
This commit is contained in:
parent
12dadbb5d0
commit
0485d191eb
@ -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(),
|
||||
|
@ -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 \
|
||||
|
50
content/base/test/test_bug465767.html
Normal file
50
content/base/test/test_bug465767.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=465767
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 465767</title>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.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=465767">Mozilla Bug 465767</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 465767 **/
|
||||
|
||||
function CC() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils)
|
||||
.garbageCollect();
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
var node = document.createElement("div");
|
||||
var e = null;
|
||||
try {
|
||||
document.implementation.createDocument("", "", null).adoptNode(node);
|
||||
CC();
|
||||
document.implementation.createDocument("", "", null).adoptNode(node);
|
||||
} catch(ex) {
|
||||
e = ex;
|
||||
}
|
||||
is(e, null, ".adoptNode didn't succeed!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(runTest);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user