From 80748548b013015ce1dac828a4bd2e7493ec5460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 4 Aug 2021 16:09:28 +0000 Subject: [PATCH] Bug 1723972 - Don't process-switch for object/embed loads if we're falling back due to an error page. r=nika Differential Revision: https://phabricator.services.mozilla.com/D121734 --- dom/base/nsObjectLoadingContent.cpp | 2 +- dom/base/nsObjectLoadingContent.h | 2 + netwerk/ipc/DocumentLoadListener.cpp | 14 +++- ...ck-failed-cross-origin-navigation.sub.html | 74 +++++++++++-------- 4 files changed, 59 insertions(+), 33 deletions(-) diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index e184b92ae2b1..4707ad06744c 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -263,7 +263,7 @@ class AutoSetLoadingToFalse { /// Helper functions /// -static bool IsSuccessfulRequest(nsIRequest* aRequest, nsresult* aStatus) { +bool nsObjectLoadingContent::IsSuccessfulRequest(nsIRequest* aRequest, nsresult* aStatus) { nsresult rv = aRequest->GetStatus(aStatus); if (NS_FAILED(rv) || NS_FAILED(*aStatus)) { return false; diff --git a/dom/base/nsObjectLoadingContent.h b/dom/base/nsObjectLoadingContent.h index 37bfd96ae0cf..5ae6bf84e111 100644 --- a/dom/base/nsObjectLoadingContent.h +++ b/dom/base/nsObjectLoadingContent.h @@ -136,6 +136,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent, // id. If in doubt, return true. static bool MayResolve(jsid aId); + static bool IsSuccessfulRequest(nsIRequest*, nsresult* aStatus); + // Helper for WebIDL enumeration void GetOwnPropertyNames(JSContext* aCx, JS::MutableHandleVector /* unused */, diff --git a/netwerk/ipc/DocumentLoadListener.cpp b/netwerk/ipc/DocumentLoadListener.cpp index abfd36b1b965..e55e95660e51 100644 --- a/netwerk/ipc/DocumentLoadListener.cpp +++ b/netwerk/ipc/DocumentLoadListener.cpp @@ -33,6 +33,7 @@ #include "nsDocShellLoadState.h" #include "nsDocShellLoadTypes.h" #include "nsDOMNavigationTiming.h" +#include "nsObjectLoadingContent.h" #include "nsExternalHelperAppService.h" #include "nsHttpChannel.h" #include "nsIBrowser.h" @@ -1526,9 +1527,16 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch( // If we're doing an / load, we may be doing a document load at // this point. We never need to do a process switch for a non-document // or load. - if (!mIsDocumentLoad && !mChannel->IsDocument()) { - LOG(("Process Switch Abort: non-document load")); - return false; + if (!mIsDocumentLoad) { + if (!mChannel->IsDocument()) { + LOG(("Process Switch Abort: non-document load")); + return false; + } + nsresult status; + if (!nsObjectLoadingContent::IsSuccessfulRequest(mChannel, &status)) { + LOG(("Process Switch Abort: error page")); + return false; + } } // Get the loading BrowsingContext. This may not be the context which will be diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-fallback-failed-cross-origin-navigation.sub.html b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-fallback-failed-cross-origin-navigation.sub.html index d2190cc7af81..09061e0349b4 100644 --- a/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-fallback-failed-cross-origin-navigation.sub.html +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-object-element/object-fallback-failed-cross-origin-navigation.sub.html @@ -1,52 +1,68 @@ -n + Test that <object> renders its own fallback.