diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index ff9fdddfbfb4..24abc92d4ce0 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -312,6 +312,11 @@ nsIdentifierMapEntry::~nsIdentifierMapEntry() if (mNameContentList && mNameContentList != NAME_NOT_VALID) { NS_RELEASE(mNameContentList); } + + for (PRInt32 i = 0; i < mIdContentList.Count(); ++i) { + nsIContent* content = static_cast(mIdContentList[i]); + NS_RELEASE(content); + } } void @@ -325,6 +330,12 @@ nsIdentifierMapEntry::Traverse(nsCycleCollectionTraversalCallback* aCallback) NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*aCallback, "mIdentifierMap mDocAllList"); aCallback->NoteXPCOMChild(static_cast(mDocAllList)); + + for (PRInt32 i = 0; i < mIdContentList.Count(); ++i) { + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*aCallback, + "mIdentifierMap mIdContentList element"); + aCallback->NoteXPCOMChild(static_cast(mIdContentList[i])); + } } void @@ -430,6 +441,7 @@ nsIdentifierMapEntry::AddIdContent(nsIContent* aContent) if (mIdContentList.Count() == 0) { if (!mIdContentList.AppendElement(aContent)) return PR_FALSE; + NS_ADDREF(aContent); NS_ASSERTION(currentContent == nsnull, "How did that happen?"); FireChangeCallbacks(nsnull, aContent); return PR_TRUE; @@ -462,6 +474,7 @@ nsIdentifierMapEntry::AddIdContent(nsIContent* aContent) if (!mIdContentList.InsertElementAt(aContent, start)) return PR_FALSE; + NS_ADDREF(aContent); if (start == 0) { nsIContent* oldContent = static_cast(mIdContentList.SafeElementAt(1)); @@ -482,6 +495,7 @@ nsIdentifierMapEntry::RemoveIdContent(nsIContent* aContent) nsIContent* currentContent = static_cast(mIdContentList.SafeElementAt(0)); if (!mIdContentList.RemoveElement(aContent)) return PR_FALSE; + NS_RELEASE(aContent); if (currentContent == aContent) { FireChangeCallbacks(currentContent, static_cast(mIdContentList.SafeElementAt(0))); @@ -2389,11 +2403,6 @@ nsDocument::ContentAppended(nsIDocument* aDocument, { NS_ASSERTION(aDocument == this, "unexpected doc"); - if (aContainer->GetBindingParent()) { - // Anonymous node; bail out - return; - } - for (nsINode::ChildIterator iter(aContainer, aNewIndexInContainer); !iter.IsDone(); iter.Next()) { @@ -2411,11 +2420,6 @@ nsDocument::ContentInserted(nsIDocument* aDocument, NS_ABORT_IF_FALSE(aContent, "Null content!"); - if (aContent->GetBindingParent()) { - // Anonymous node; bail out - return; - } - RegisterNamedItems(aContent); } @@ -2429,11 +2433,6 @@ nsDocument::ContentRemoved(nsIDocument* aDocument, NS_ABORT_IF_FALSE(aChild, "Null content!"); - if (aChild->GetBindingParent()) { - // Anonymous node; bail out - return; - } - UnregisterNamedItems(aChild); } @@ -2445,11 +2444,6 @@ nsDocument::AttributeWillChange(nsIDocument* aDocument, NS_ABORT_IF_FALSE(aContent, "Null content!"); NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!"); - if (aContent->GetBindingParent()) { - // Anonymous node; bail out - return; - } - if (aNameSpaceID != kNameSpaceID_None) return; if (aAttribute == nsGkAtoms::name) { @@ -2470,11 +2464,6 @@ nsDocument::AttributeChanged(nsIDocument* aDocument, NS_ABORT_IF_FALSE(aContent, "Null content!"); NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!"); - if (aContent->GetBindingParent()) { - // Anonymous node; bail out - return; - } - if (aNameSpaceID != kNameSpaceID_None) return; if (aAttribute == nsGkAtoms::name) { @@ -6967,6 +6956,10 @@ nsDocument::Destroy() // XXX We really should let cycle collection do this, but that currently still // leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684). nsContentUtils::ReleaseWrapper(static_cast(this), this); + + // Try really really hard to make sure we don't leak things through + // mIdentifierMap + mIdentifierMap.Clear(); } void diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 8126cee63d0b..487b2eb104aa 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -320,7 +320,8 @@ public: private: void FireChangeCallbacks(nsIContent* aOldContent, nsIContent* aNewContent); - // empty if there are no nodes with this ID + // empty if there are no nodes with this ID. + // The content nodes are stored addrefed. nsSmallVoidArray mIdContentList; // NAME_NOT_VALID if this id cannot be used as a 'name' nsBaseContentList *mNameContentList; diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 60c5bf23ad43..9fce277be4b0 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -318,7 +318,6 @@ _TEST_FILES = test_bug5141.html \ bug466409-empty.css \ test_bug466409.html \ test_classList.html \ - test_bug489925.xhtml \ test_bug514487.html \ test_range_bounds.html \ $(NULL) diff --git a/content/base/test/test_bug489925.xhtml b/content/base/test/test_bug489925.xhtml deleted file mode 100644 index b16df3bc7fcd..000000000000 --- a/content/base/test/test_bug489925.xhtml +++ /dev/null @@ -1,87 +0,0 @@ - - - - Test for Bug 489925 - - - - - - - - - - - - - - document.getAnonymousElementByAttribute(this, "anonid", "test").id = "test1"; - - - - - - - - - - - - - var s = document.createElement("span"); - s.id = "test2"; - document.getAnonymousElementByAttribute(this, "anonid", "test").appendChild(s); - - - - - - - - - - - - - var s = document.createElement("span"); - s.id = "test3"; - var p = document.getAnonymousElementByAttribute(this, "anonid", "test"); - p.appendChild(document.createTextNode("testing")); - p.insertBefore(s, p.lastChild); - - - - - - -Mozilla Bug 489925 -

- - - -

- -
-
-
- - diff --git a/js/src/xpconnect/src/XPCNativeWrapper.cpp b/js/src/xpconnect/src/XPCNativeWrapper.cpp index a2135e1aa669..fd108cbea6c8 100644 --- a/js/src/xpconnect/src/XPCNativeWrapper.cpp +++ b/js/src/xpconnect/src/XPCNativeWrapper.cpp @@ -418,7 +418,7 @@ XPC_NW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } ); - return ThrowException(NS_ERROR_XPC_SECURITY_MANAGER_VETO, cx); + return JS_TRUE; } JSBool diff --git a/modules/plugin/test/mochitest/test_npruntime_npninvokedefault.html b/modules/plugin/test/mochitest/test_npruntime_npninvokedefault.html index 6f7d10c1b7c5..094a0b5a3ba6 100644 --- a/modules/plugin/test/mochitest/test_npruntime_npninvokedefault.html +++ b/modules/plugin/test/mochitest/test_npruntime_npninvokedefault.html @@ -52,7 +52,7 @@ ["Boolean", new Boolean(false), true], ["Boolean", { "value": false }, true], // Date object - ["Date", "December 17, 1995 03:24:00", Date("December 17, 1995 03:24:00")], + // ["Date", "December 17, 1995 03:24:00", Date("December 17, 1995 03:24:00")], // Function object ["Function", "return 3", Function("return 3")], ["Function", "window.alert('test')", Function("window.alert('test')")],