diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index cb401578d162..72085b0148fb 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -21,6 +21,7 @@ #include "mozilla/dom/BindContext.h" #include "mozilla/dom/Flex.h" #include "mozilla/dom/Grid.h" +#include "mozilla/dom/Link.h" #include "mozilla/dom/ScriptLoader.h" #include "mozilla/dom/Text.h" #include "mozilla/gfx/Matrix.h" @@ -4380,5 +4381,14 @@ double Element::FirstLineBoxBSize() const { : 0.0; } +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED +void Element::AssertInvariantsOnNodeInfoChange() { + MOZ_DIAGNOSTIC_ASSERT(!IsInComposedDoc()); + if (nsCOMPtr link = do_QueryInterface(this)) { + MOZ_DIAGNOSTIC_ASSERT(!link->HasPendingLinkUpdate()); + } +} +#endif + } // namespace dom } // namespace mozilla diff --git a/dom/base/Element.h b/dom/base/Element.h index 358ffa412dec..b8bded46909e 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -1468,7 +1468,11 @@ class Element : public FragmentOrElement { * * If you change this, change also the similar method in Link. */ - virtual void NodeInfoChanged(Document* aOldDoc) {} + virtual void NodeInfoChanged(Document* aOldDoc) { +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED + AssertInvariantsOnNodeInfoChange(); +#endif + } /** * Parse a string into an nsAttrValue for a CORS attribute. This @@ -1917,6 +1921,10 @@ class Element : public FragmentOrElement { ReparseAttributes = ReparseAttributes::Yes); private: +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED + void AssertInvariantsOnNodeInfoChange(); +#endif + /** * Slow path for GetClasses, this should only be called for SVG elements. */