Bug 1599616 - Don't try to save document when document actor has been destroyed. r=smaug
authorAndreas Farre <farre@mozilla.com>
Mon, 26 Oct 2020 19:19:51 +0000
changeset 554614 b631c11d4acfbf1b5952a6dd91a882b892c0c0af
parent 554613 badfff22ee8b50ab5ea56fbc93d1e22744454328
child 554615 0ade4b1a15d7b004ed691f46a537594c1dfb8ceb
push id129500
push userafarre@mozilla.com
push dateTue, 27 Oct 2020 09:45:54 +0000
treeherderautoland@b631c11d4acf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1599616
milestone84.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1599616 - Don't try to save document when document actor has been destroyed. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D94733
dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp
dom/webbrowserpersist/WebBrowserPersistRemoteDocument.cpp
dom/webbrowserpersist/nsIWebBrowserPersistDocument.idl
dom/webbrowserpersist/nsWebBrowserPersist.cpp
toolkit/components/windowcreator/test/browser.ini
--- a/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp
+++ b/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp
@@ -75,16 +75,22 @@ WebBrowserPersistLocalDocument::SetPersi
 
 NS_IMETHODIMP
 WebBrowserPersistLocalDocument::GetPersistFlags(uint32_t* aFlags) {
   *aFlags = mPersistFlags;
   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();
   *aIsPrivate = privacyContext && privacyContext->UsePrivateBrowsing();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WebBrowserPersistLocalDocument::GetDocumentURI(nsACString& aURISpec) {
--- a/dom/webbrowserpersist/WebBrowserPersistRemoteDocument.cpp
+++ b/dom/webbrowserpersist/WebBrowserPersistRemoteDocument.cpp
@@ -37,16 +37,22 @@ WebBrowserPersistRemoteDocument::~WebBro
     // (whether or not the IPC send succeeds).
   }
   MOZ_ASSERT(!mActor);
 }
 
 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();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WebBrowserPersistRemoteDocument::GetDocumentURI(nsACString& aURISpec) {
   aURISpec = mAttrs.documentURI();
--- a/dom/webbrowserpersist/nsIWebBrowserPersistDocument.idl
+++ b/dom/webbrowserpersist/nsIWebBrowserPersistDocument.idl
@@ -54,16 +54,17 @@ interface nsIWebBrowserPersistURIMap : n
  * nsIWebBrowserPersist; it may or may not be in this process.  Some
  * information is exposed as attributes, which may or may not reflect
  * changes made to the underlying document; most of these are
  * self-explanatory from their names and types.
  */
 [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;
   readonly attribute ACString contentType;
   readonly attribute ACString characterSet;
   readonly attribute AString title;
   readonly attribute nsIReferrerInfo referrerInfo;
   readonly attribute AString contentDisposition;
--- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -503,20 +503,23 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveD
   if (!doc) {
     nsCOMPtr<Document> localDoc = do_QueryInterface(aDocument);
     if (localDoc) {
       doc = new mozilla::WebBrowserPersistLocalDocument(localDoc);
     } else {
       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);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsWebBrowserPersist::Cancel(nsresult aReason) {
   // No point cancelling if we're already complete.
--- a/toolkit/components/windowcreator/test/browser.ini
+++ b/toolkit/components/windowcreator/test/browser.ini
@@ -1,11 +1,9 @@
 [browser_bug1204626.js]
-fail-if = fission && !debug
-skip-if = fission && os == 'linux' && debug
 support-files =
   bug1204626_doc0.html
   bug1204626_doc1.html
 [browser_save_form_input_state.js]
 support-files =
   file_form_state.html
 [browser_persist.js]
 support-files =