Bug 1599616 - Don't try to save document when document actor has been destroyed. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D94733
This commit is contained in:
Andreas Farre 2020-10-26 19:19:51 +00:00
parent 23aba1fe38
commit 1e4c7e1c01
5 changed files with 18 additions and 4 deletions

View File

@ -79,6 +79,12 @@ WebBrowserPersistLocalDocument::GetPersistFlags(uint32_t* aFlags) {
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistLocalDocument::GetIsClosed(bool* aIsClosed) {
*aIsClosed = false;
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistLocalDocument::GetIsPrivate(bool* aIsPrivate) {
nsCOMPtr<nsILoadContext> privacyContext = mDocument->GetLoadContext();

View File

@ -41,6 +41,12 @@ WebBrowserPersistRemoteDocument::~WebBrowserPersistRemoteDocument() {
void WebBrowserPersistRemoteDocument::ActorDestroy(void) { mActor = nullptr; }
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetIsClosed(bool* aIsClosed) {
*aIsClosed = !mActor;
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetIsPrivate(bool* aIsPrivate) {
*aIsPrivate = mAttrs.isPrivate();

View File

@ -59,6 +59,7 @@ interface nsIWebBrowserPersistURIMap : nsISupports
[scriptable, builtinclass, uuid(74aa4918-5d15-46b6-9ccf-74f9696d721d)]
interface nsIWebBrowserPersistDocument : nsISupports
{
readonly attribute boolean isClosed;
readonly attribute boolean isPrivate;
readonly attribute AUTF8String documentURI;
readonly attribute AUTF8String baseURI;

View File

@ -508,10 +508,13 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveDocument(nsISupports* aDocument,
rv = NS_ERROR_NO_INTERFACE;
}
}
if (doc) {
bool closed = false;
if (doc && NS_SUCCEEDED(doc->GetIsClosed(&closed)) && !closed) {
rv = SaveDocumentInternal(doc, fileAsURI, datapathAsURI);
}
if (NS_FAILED(rv)) {
if (NS_FAILED(rv) || closed) {
SendErrorStatusChange(true, rv, nullptr, mURI);
EndDownload(rv);
}

View File

@ -1,6 +1,4 @@
[browser_bug1204626.js]
fail-if = fission && !debug
skip-if = fission && os == 'linux' && debug
support-files =
bug1204626_doc0.html
bug1204626_doc1.html