diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp index 55cf7d5118..7aa3a5d14d 100644 --- a/docshell/base/nsDSURIContentListener.cpp +++ b/docshell/base/nsDSURIContentListener.cpp @@ -136,7 +136,7 @@ nsDSURIContentListener::DoContent(const nsACString& aContentType, mExistingJPEGRequest = baseChannel; } - if (rv == NS_ERROR_REMOTE_XUL) { + if (rv == NS_ERROR_REMOTE_XUL || rv == NS_ERROR_DOCSHELL_DYING) { aRequest->Cancel(rv); *aAbortProcess = true; return NS_OK; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index d2e1af36b3..2ff5273d93 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9040,6 +9040,12 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType, { *aContentHandler = nullptr; + if (!mTreeOwner) { + // If we don't have a tree owner, then we're in the process of being + // destroyed. Rather than continue trying to load something, just give up. + return NS_ERROR_DOCSHELL_DYING; + } + // Can we check the content type of the current content viewer // and reuse it without destroying it and re-creating it? diff --git a/xpcom/base/ErrorList.h b/xpcom/base/ErrorList.h index 192bc16e06..195b72998b 100644 --- a/xpcom/base/ErrorList.h +++ b/xpcom/base/ErrorList.h @@ -247,6 +247,9 @@ ERROR(NS_ERROR_REMOTE_XUL, FAILURE(75)), /* The request resulted in an error page being displayed. */ ERROR(NS_ERROR_LOAD_SHOWED_ERRORPAGE, FAILURE(77)), + /* The request occurred in docshell that lacks a treeowner, so it is + * probably in the process of being torn down. */ + ERROR(NS_ERROR_DOCSHELL_DYING, FAILURE(78)), /* FTP specific error codes: */