diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 053a5307d03b..7e681306bb85 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -837,6 +837,22 @@ nsresult BrowsingContext::LoadURI(BrowsingContext* aAccessor, return NS_OK; } +void BrowsingContext::DisplayLoadError(const nsAString& aURI) { + MOZ_LOG(GetLog(), LogLevel::Debug, ("DisplayLoadError")); + MOZ_DIAGNOSTIC_ASSERT(!IsDiscarded()); + MOZ_DIAGNOSTIC_ASSERT(mDocShell || XRE_IsParentProcess()); + + if (mDocShell) { + bool didDisplayLoadError = false; + mDocShell->DisplayLoadError(NS_ERROR_MALFORMED_URI, nullptr, + PromiseFlatString(aURI).get(), nullptr, + &didDisplayLoadError); + } else { + Unused << Canonical()->GetCurrentWindowGlobal()->SendDisplayLoadError( + PromiseFlatString(aURI)); + } +} + void BrowsingContext::Close(CallerType aCallerType, ErrorResult& aError) { // FIXME We need to set mClosed, but only once we're sending the // DOMWindowClose event (which happens in the process where the diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index 5cf08f05d0ea..df4b422688a7 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -188,6 +188,8 @@ class BrowsingContext : public nsWrapperCache, public BrowsingContextBase { nsresult LoadURI(BrowsingContext* aAccessor, nsDocShellLoadState* aLoadState, bool aSetNavigating = false); + void DisplayLoadError(const nsAString& aURI); + // Determine if the current BrowsingContext was 'cached' by the logic in // CacheChildren. bool IsCached(); diff --git a/dom/ipc/PWindowGlobal.ipdl b/dom/ipc/PWindowGlobal.ipdl index 130f2b344085..fed9600f759b 100644 --- a/dom/ipc/PWindowGlobal.ipdl +++ b/dom/ipc/PWindowGlobal.ipdl @@ -62,6 +62,8 @@ child: async LoadURIInChild(nsDocShellLoadState aLoadState, bool aSetNavigating); + async DisplayLoadError(nsString aURI); + both: async RawMessage(JSWindowActorMessageMeta aMetadata, ClonedMessageData aData); diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index 003dadad1bcd..1cd96d5da5fe 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -242,6 +242,16 @@ mozilla::ipc::IPCResult WindowGlobalChild::RecvLoadURIInChild( return IPC_OK(); } +mozilla::ipc::IPCResult WindowGlobalChild::RecvDisplayLoadError( + const nsAString& aURI) { + bool didDisplayLoadError = false; + mWindowGlobal->GetDocShell()->DisplayLoadError( + NS_ERROR_MALFORMED_URI, nullptr, PromiseFlatString(aURI).get(), nullptr, + &didDisplayLoadError); + mWindowGlobal->GetBrowserChild()->NotifyNavigationFinished(); + return IPC_OK(); +} + static nsresult ChangeFrameRemoteness(WindowGlobalChild* aWgc, BrowsingContext* aBc, const nsString& aRemoteType, diff --git a/dom/ipc/WindowGlobalChild.h b/dom/ipc/WindowGlobalChild.h index 4dd89c68e896..b669bbd5fc75 100644 --- a/dom/ipc/WindowGlobalChild.h +++ b/dom/ipc/WindowGlobalChild.h @@ -117,6 +117,8 @@ class WindowGlobalChild final : public WindowGlobalActor, mozilla::ipc::IPCResult RecvLoadURIInChild(nsDocShellLoadState* aLoadState, bool aSetNavigating); + mozilla::ipc::IPCResult RecvDisplayLoadError(const nsAString& aURI); + mozilla::ipc::IPCResult RecvChangeFrameRemoteness( dom::BrowsingContext* aBc, const nsString& aRemoteType, uint64_t aPendingSwitchId, ChangeFrameRemotenessResolver&& aResolver);