From 14231076582dd4b2484ea406eaa2581020291725 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 16 May 2013 23:33:14 -0700 Subject: [PATCH] Bug 860941 - Clarify shutdown invariants in ~nsGlobalWindow. r=jst While the mArguments invariant should hold for _outers_, it doesn't necessarily hold for inners, so this assertion fires reliably in automation. If mCleanedUp is true then mArguments is definitely null, so let's disentangle this from mArguments and be clearer about the invariants we expect. --- dom/base/nsGlobalWindow.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f537d84f866..e4286b187d4 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1232,9 +1232,16 @@ nsGlobalWindow::~nsGlobalWindow() mDoc = nullptr; - NS_ASSERTION(!mArguments, "mArguments wasn't cleaned up properly!"); - - CleanUp(true); + // Outer windows are always supposed to call CleanUp before letting themselves + // be destroyed. And while CleanUp generally seems to be intended to clean up + // outers, we've historically called it for both. Changing this would probably + // involve auditing all of the references that inners and outers can have, and + // separating the handling into CleanUp() and FreeInnerObjects. + if (IsInnerWindow()) { + CleanUp(true); + } else { + MOZ_ASSERT(mCleanedUp); + } nsCOMPtr ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID); if (ac)