Backed out changeset 3e349b00a1e4 (bug 1649349) for causing failures in browser_CORS-console-warnings.js

This commit is contained in:
Noemi Erli 2020-07-02 14:01:25 +03:00
Родитель 355f38ec2f
Коммит d60357a61d
7 изменённых файлов: 33 добавлений и 50 удалений

Просмотреть файл

@ -123,15 +123,8 @@ IPCResult DocumentChannelChild::RecvFailedAsyncOpen(
} }
IPCResult DocumentChannelChild::RecvDisconnectChildListeners( IPCResult DocumentChannelChild::RecvDisconnectChildListeners(
const nsresult& aStatus, const nsresult& aLoadGroupStatus, const nsresult& aStatus, const nsresult& aLoadGroupStatus) {
bool aSwitchedProcess) { DisconnectChildListeners(aStatus, aLoadGroupStatus);
// If this is a normal failure, then we want to disconnect our listeners and
// notify them of the failure. If this is a process switch, then we can just
// ignore it silently, and trust that the switch will shut down our docshell
// and cancel us when it's ready.
if (!aSwitchedProcess) {
DisconnectChildListeners(aStatus, aLoadGroupStatus);
}
return IPC_OK(); return IPC_OK();
} }

Просмотреть файл

@ -38,8 +38,7 @@ class DocumentChannelChild final : public DocumentChannel,
mozilla::ipc::IPCResult RecvFailedAsyncOpen(const nsresult& aStatusCode); mozilla::ipc::IPCResult RecvFailedAsyncOpen(const nsresult& aStatusCode);
mozilla::ipc::IPCResult RecvDisconnectChildListeners( mozilla::ipc::IPCResult RecvDisconnectChildListeners(
const nsresult& aStatus, const nsresult& aLoadGroupStatus, const nsresult& aStatus, const nsresult& aLoadGroupStatus);
bool aSwitchedProcess);
mozilla::ipc::IPCResult RecvDeleteSelf(); mozilla::ipc::IPCResult RecvDeleteSelf();

Просмотреть файл

@ -79,11 +79,11 @@ bool DocumentChannelParent::Init(dom::CanonicalBrowsingContext* aContext,
self->mDocumentLoadListener = nullptr; self->mDocumentLoadListener = nullptr;
}, },
[self](DocumentLoadListener::OpenPromiseFailedType&& aRejectValue) { [self](DocumentLoadListener::OpenPromiseFailedType&& aRejectValue) {
if (self->CanSend()) { if (!self->CanSend()) {
Unused << self->SendDisconnectChildListeners( return;
aRejectValue.mStatus, aRejectValue.mLoadGroupStatus,
aRejectValue.mSwitchedProcess);
} }
Unused << self->SendDisconnectChildListeners(
aRejectValue.mStatus, aRejectValue.mLoadGroupStatus);
self->mDocumentLoadListener = nullptr; self->mDocumentLoadListener = nullptr;
}); });

Просмотреть файл

@ -14,7 +14,6 @@
#include "mozilla/StaticPrefs_extensions.h" #include "mozilla/StaticPrefs_extensions.h"
#include "mozilla/StaticPrefs_fission.h" #include "mozilla/StaticPrefs_fission.h"
#include "mozilla/StaticPrefs_security.h" #include "mozilla/StaticPrefs_security.h"
#include "mozilla/dom/BrowserParent.h"
#include "mozilla/dom/BrowsingContextGroup.h" #include "mozilla/dom/BrowsingContextGroup.h"
#include "mozilla/dom/CanonicalBrowsingContext.h" #include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ChildProcessChannelListener.h" #include "mozilla/dom/ChildProcessChannelListener.h"
@ -798,9 +797,15 @@ void DocumentLoadListener::Cancel(const nsresult& aStatusCode) {
("DocumentLoadListener Cancel [this=%p, " ("DocumentLoadListener Cancel [this=%p, "
"aStatusCode=%" PRIx32 " ]", "aStatusCode=%" PRIx32 " ]",
this, static_cast<uint32_t>(aStatusCode))); this, static_cast<uint32_t>(aStatusCode)));
if (mOpenPromiseResolved) { mCancelled = true;
if (mDoingProcessSwitch) {
// If we've already initiated process-switching
// then we can no longer be cancelled and we'll
// disconnect the old listeners when done.
return; return;
} }
if (mChannel) { if (mChannel) {
mChannel->Cancel(aStatusCode); mChannel->Cancel(aStatusCode);
} }
@ -821,16 +826,12 @@ void DocumentLoadListener::DisconnectListeners(nsresult aStatus,
Disconnect(); Disconnect();
if (!aSwitchedProcess) { // If we're not going to send anything else to the content process, and
// If we're not going to send anything else to the content process, and // we haven't yet consumed a stream filter promise, then we're never going
// we haven't yet consumed a stream filter promise, then we're never going // to.
// to. If we're disconnecting the old content process due to a proces // TODO: This might be because we retargeted the stream to the download
// switch, then we can rely on FinishReplacementChannelSetup being called // handler or similar. Do we need to attach a stream filter to that?
// (even if the switch failed), so we clear at that point instead. mStreamFilterRequests.Clear();
// TODO: This might be because we retargeted the stream to the download
// handler or similar. Do we need to attach a stream filter to that?
mStreamFilterRequests.Clear();
}
} }
void DocumentLoadListener::RedirectToRealChannelFinished(nsresult aRv) { void DocumentLoadListener::RedirectToRealChannelFinished(nsresult aRv) {
@ -886,7 +887,11 @@ void DocumentLoadListener::FinishReplacementChannelSetup(nsresult aResult) {
ctx->EndDocumentLoad(false); ctx->EndDocumentLoad(false);
} }
}); });
mStreamFilterRequests.Clear();
if (mDoingProcessSwitch) {
DisconnectListeners(NS_BINDING_ABORTED, NS_BINDING_ABORTED,
NS_SUCCEEDED(aResult));
}
nsCOMPtr<nsIRedirectChannelRegistrar> registrar = nsCOMPtr<nsIRedirectChannelRegistrar> registrar =
RedirectChannelRegistrar::GetOrCreate(); RedirectChannelRegistrar::GetOrCreate();
@ -1304,8 +1309,8 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
// Get information about the current document loaded in our BrowsingContext. // Get information about the current document loaded in our BrowsingContext.
nsCOMPtr<nsIPrincipal> currentPrincipal; nsCOMPtr<nsIPrincipal> currentPrincipal;
RefPtr<WindowGlobalParent> wgp = browsingContext->GetCurrentWindowGlobal(); if (RefPtr<WindowGlobalParent> wgp =
if (wgp) { browsingContext->GetCurrentWindowGlobal()) {
currentPrincipal = wgp->DocumentPrincipal(); currentPrincipal = wgp->DocumentPrincipal();
} }
RefPtr<ContentParent> contentParent = browsingContext->GetContentParent(); RefPtr<ContentParent> contentParent = browsingContext->GetContentParent();
@ -1424,18 +1429,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
NS_ConvertUTF16toUTF8(currentRemoteType).get(), NS_ConvertUTF16toUTF8(currentRemoteType).get(),
NS_ConvertUTF16toUTF8(remoteType).get())); NS_ConvertUTF16toUTF8(remoteType).get()));
// We're now committing to a process switch, so we can disconnect from
// the listeners in the old process.
mDoingProcessSwitch = true; mDoingProcessSwitch = true;
if (wgp) {
if (RefPtr<BrowserParent> browserParent = wgp->GetBrowserParent()) {
// This load has already started, so we want to filter out any 'stop'
// progress events coming from the old process as a result of us
// disconnecting from it.
browserParent->SuspendProgressEventsUntilAfterNextLoadStarts();
}
}
DisconnectListeners(NS_BINDING_ABORTED, NS_BINDING_ABORTED, true);
LOG(("Process Switch: Calling ChangeRemoteness")); LOG(("Process Switch: Calling ChangeRemoteness"));
browsingContext browsingContext

Просмотреть файл

@ -468,6 +468,9 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
// passed to the childChannel in order to identify it in the new process. // passed to the childChannel in order to identify it in the new process.
uint64_t mLoadIdentifier = 0; uint64_t mLoadIdentifier = 0;
// True if cancelled.
bool mCancelled = false;
Maybe<nsCString> mOriginalUriString; Maybe<nsCString> mOriginalUriString;
bool mSupportsRedirectToRealChannel = true; bool mSupportsRedirectToRealChannel = true;

Просмотреть файл

@ -46,7 +46,7 @@ child:
// the loadgroup (but aStatus is passed as the parameter to RemoveRequest). // the loadgroup (but aStatus is passed as the parameter to RemoveRequest).
// We do this so we can remove using NS_BINDING_RETARGETED, but still have the // We do this so we can remove using NS_BINDING_RETARGETED, but still have the
// channel not be in an error state. // channel not be in an error state.
async DisconnectChildListeners(nsresult aStatus, nsresult aLoadGroupReason, bool aSwitchedProcess); async DisconnectChildListeners(nsresult aStatus, nsresult aLoadGroupReason);
// Triggers replacing this DocumentChannel with a 'real' channel (like PHttpChannel), // Triggers replacing this DocumentChannel with a 'real' channel (like PHttpChannel),
// and notifies the listener via a redirect to the new channel. // and notifies the listener via a redirect to the new channel.

Просмотреть файл

@ -204,14 +204,8 @@ NS_IMETHODIMP ParentProcessDocumentChannel::AsyncOpen(
p->ChainTo(aResolveValue.mPromise.forget(), __func__); p->ChainTo(aResolveValue.mPromise.forget(), __func__);
}, },
[self](DocumentLoadListener::OpenPromiseFailedType&& aRejectValue) { [self](DocumentLoadListener::OpenPromiseFailedType&& aRejectValue) {
// If this is a normal failure, then we want to disconnect our listeners self->DisconnectChildListeners(aRejectValue.mStatus,
// and notify them of the failure. If this is a process switch, then we aRejectValue.mLoadGroupStatus);
// can just ignore it silently, and trust that the switch will shut down
// our docshell and cancel us when it's ready.
if (!aRejectValue.mSwitchedProcess) {
self->DisconnectChildListeners(aRejectValue.mStatus,
aRejectValue.mLoadGroupStatus);
}
self->RemoveObserver(); self->RemoveObserver();
}); });
return NS_OK; return NS_OK;