Bug 951991 - Assert against calling GetCurrentInnerWindow on an inner. r=smaug

The current convention is that this returns null when invoked on an inner, which
callers may or may not handle correctly. But when we start using GetEntryGlobal,
we'll end up with a lot of inners where we used to get outers, so we should get
strict about this now.
This commit is contained in:
Bobby Holley 2014-08-19 12:02:05 -07:00
parent 2f6f5ef5f9
commit 025dd6cc2c
6 changed files with 15 additions and 16 deletions

View File

@ -420,7 +420,7 @@ nsFocusManager::GetLastFocusMethod(nsIDOMWindow* aWindow, uint32_t* aLastFocusMe
{
// the focus method is stored on the inner window
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aWindow));
if (window)
if (window && window->IsOuterWindow())
window = window->GetCurrentInnerWindow();
if (!window)
window = mFocusedWindow;

View File

@ -1482,10 +1482,11 @@ nsGlobalWindow::CleanUp()
mChromeEventHandler = nullptr; // Forces Release
mParentTarget = nullptr;
nsGlobalWindow *inner = GetCurrentInnerWindowInternal();
if (inner) {
inner->CleanUp();
if (IsOuterWindow()) {
nsGlobalWindow* inner = GetCurrentInnerWindowInternal();
if (inner) {
inner->CleanUp();
}
}
if (IsInnerWindow()) {

View File

@ -599,6 +599,7 @@ public:
nsGlobalWindow *GetCurrentInnerWindowInternal() const
{
MOZ_ASSERT(IsOuterWindow());
return static_cast<nsGlobalWindow *>(mInnerWindow);
}

View File

@ -192,12 +192,7 @@ public:
bool IsLoadingOrRunningTimeout() const
{
const nsPIDOMWindow *win = GetCurrentInnerWindow();
if (!win) {
win = this;
}
const nsPIDOMWindow* win = IsInnerWindow() ? this : GetCurrentInnerWindow();
return !win->mIsDocumentLoaded || win->mRunningTimeout;
}
@ -299,6 +294,7 @@ public:
nsPIDOMWindow *GetCurrentInnerWindow() const
{
MOZ_ASSERT(IsOuterWindow());
return mInnerWindow;
}

View File

@ -56,7 +56,8 @@ AddNonJSSizeOfWindowAndItsDescendents(nsGlobalWindow* aWindow,
// Measure the inner window, if there is one.
nsWindowSizes innerWindowSizes(moz_malloc_size_of);
nsGlobalWindow* inner = aWindow->GetCurrentInnerWindowInternal();
nsGlobalWindow* inner = aWindow->IsOuterWindow() ? aWindow->GetCurrentInnerWindowInternal()
: nullptr;
if (inner) {
inner->AddSizeOfIncludingThis(&innerWindowSizes);
innerWindowSizes.addToTabSizes(aSizes);

View File

@ -2102,12 +2102,12 @@ MediaManager::MediaCaptureWindowStateInternal(nsIDOMWindow* aWindow, bool* aVide
// results.
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryInterface(aWindow);
if (piWin) {
if (piWin->GetCurrentInnerWindow() || piWin->IsInnerWindow()) {
if (piWin->IsInnerWindow() || piWin->GetCurrentInnerWindow()) {
uint64_t windowID;
if (piWin->GetCurrentInnerWindow()) {
windowID = piWin->GetCurrentInnerWindow()->WindowID();
} else {
if (piWin->IsInnerWindow()) {
windowID = piWin->WindowID();
} else {
windowID = piWin->GetCurrentInnerWindow()->WindowID();
}
StreamListeners* listeners = GetActiveWindows()->Get(windowID);
if (listeners) {