Bug 2060799 - Harden against re-bindign an already-parented node. r=smaug,dom-core-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D316497
This commit is contained in:
Vincent Hilla
2026-08-06 07:16:09 +00:00
committed by vhilla@mozilla.com
parent 46897803d4
commit 19bb88fc72
3 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -377,8 +377,8 @@ nsresult CharacterData::BindToTree(BindContext& aContext, nsINode& aParent) {
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
// Note that as we recurse into the kids, they'll have a non-null parent. So
// only assert if our parent is _changing_ while we have a parent.
MOZ_ASSERT(!GetParentNode() || &aParent == GetParentNode(),
"Already have a parent. Unbind first!");
MOZ_DIAGNOSTIC_ASSERT(!GetParentNode() || &aParent == GetParentNode(),
"Already have a different parent. Unbind first!");
const bool hadParent = !!GetParentNode();
+2 -2
View File
@@ -2925,8 +2925,8 @@ nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) {
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
// Note that as we recurse into the kids, they'll have a non-null parent. So
// only assert if our parent is _changing_ while we have a parent.
MOZ_ASSERT(!GetParentNode() || &aParent == GetParentNode(),
"Already have a parent. Unbind first!");
MOZ_DIAGNOSTIC_ASSERT(!GetParentNode() || &aParent == GetParentNode(),
"Already have a different parent. Unbind first!");
const bool hadParent = !!GetParentNode();
+2 -1
View File
@@ -2147,7 +2147,8 @@ void nsINode::InsertChildBefore(
return;
}
MOZ_ASSERT(!aKid->GetParentNode(), "Inserting node that already has parent");
MOZ_DIAGNOSTIC_ASSERT(!aKid->GetParentNode(),
"Inserting node that already has parent");
MOZ_ASSERT(!IsAttr());
// The id-handling code, and in the future possibly other code, need to