Bug 455853 - Javascript: User defined properties disappear after 3 to 10 seconds from nodes that are added to a DOM document that is created using document.implementation.createDocument(), r+sr=peterv

This commit is contained in:
Olli Pettay 2008-09-24 12:47:35 +03:00
parent 32d0949e81
commit 6184f52ec8
3 changed files with 45 additions and 1 deletions

View File

@ -5760,7 +5760,9 @@ nsDocument::FlushPendingNotifications(mozFlushType aType)
void void
nsDocument::AddReference(void *aKey, nsISupports *aReference) nsDocument::AddReference(void *aKey, nsISupports *aReference)
{ {
if (mScriptGlobalObject) { PRBool dummy;
nsIScriptGlobalObject* scriptObject = GetScriptHandlingObject(dummy);
if (scriptObject) {
if (!mContentWrapperHash) { if (!mContentWrapperHash) {
mContentWrapperHash = new nsInterfaceHashtable<nsVoidPtrHashKey, nsISupports>; mContentWrapperHash = new nsInterfaceHashtable<nsVoidPtrHashKey, nsISupports>;
if (mContentWrapperHash) { if (mContentWrapperHash) {

View File

@ -212,6 +212,7 @@ _TEST_FILES = test_bug5141.html \
test_bug368972.html \ test_bug368972.html \
test_bug450160.html \ test_bug450160.html \
test_bug454326.html \ test_bug454326.html \
test_bug455853.html \
$(NULL) $(NULL)
libs:: $(_TEST_FILES) libs:: $(_TEST_FILES)

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=455853
-->
<head>
<title>Test for Bug 455853</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=455853">Mozilla Bug 455853</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 455853 **/
function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var doc = document.implementation.createDocument("", "", null);
var root = doc.createElement('nodes');
doc.appendChild(root);
root.expando = "ok";
root = null;
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.garbageCollect();
ok(doc.documentElement.expando, "Should have preserved the expando!");
}
runTest();
</script>
</pre>
</body>
</html>