Bug 1401379 - Part 8: Avoid using mDocShell to check if the window has been closed, r=smaug

MozReview-Commit-ID: CyNanVzyyNp
This commit is contained in:
Nika Layzell
2017-10-02 10:58:57 -04:00
parent 6332e70807
commit 9fcd7adeb9
3 changed files with 28 additions and 5 deletions

View File

@@ -828,6 +828,7 @@ nsDocShell::nsDocShell()
, mEODForCurrentDocument(false)
, mURIResultedInDocument(false)
, mIsBeingDestroyed(false)
, mScriptGlobalDead(false)
, mIsExecutingOnLoadHandler(false)
, mIsPrintingOrPP(false)
, mSavingOldViewer(false)
@@ -5978,8 +5979,9 @@ nsDocShell::Destroy()
mParentWidget = nullptr;
mCurrentURI = nullptr;
if (mScriptGlobal) {
if (mScriptGlobal && !mScriptGlobalDead) {
mScriptGlobal->DetachFromDocShell();
mScriptGlobalDead = true;
}
if (mSessionHistory) {
@@ -13623,6 +13625,12 @@ NS_IMETHODIMP
nsDocShell::EnsureScriptEnvironment()
{
if (mScriptGlobal) {
// If the script global is dead, we may still have it around but we don't
// want to expose it from methods such as GetInterface, as their consumers
// will expect a non-dead window.
if (mScriptGlobalDead) {
return NS_ERROR_NOT_AVAILABLE;
}
return NS_OK;
}