Bug 1553267 - Cancel the redirect load if docshell is being destroyed r=mayhemer

When the docshell is being destroyed, HttpChannelChild::CompleteRedirectSetup is not called and HttpChannelChild::mListener is not also assigned. In this case, I think we should cancel the channel and propagate the error to the http channel parent.

Differential Revision: https://phabricator.services.mozilla.com/D41515

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kershaw Chang 2019-08-16 11:41:04 +00:00
parent c0a595d089
commit fb1430c0de
3 changed files with 14 additions and 2 deletions

View File

@ -13218,6 +13218,10 @@ nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier, int32_t aHistoryIndex) {
cpcl->RegisterCallback(
aIdentifier, [self, aHistoryIndex](nsIChildChannel* aChannel) {
if (NS_WARN_IF(self->mIsBeingDestroyed)) {
nsCOMPtr<nsIRequest> request = do_QueryInterface(aChannel);
if (request) {
request->Cancel(NS_BINDING_ABORTED);
}
return;
}

View File

@ -4058,6 +4058,10 @@ nsresult HttpChannelChild::CrossProcessRedirectFinished(nsresult aStatus) {
return NS_BINDING_FAILED;
}
if (!mCanceled && NS_SUCCEEDED(mStatus)) {
mStatus = aStatus;
}
// The loadInfo is updated in nsDocShell::OpenInitializedChannel to have the
// correct attributes (such as browsingContextID).
// We need to send it to the parent channel so the two match, which is done
@ -4066,7 +4070,7 @@ nsresult HttpChannelChild::CrossProcessRedirectFinished(nsresult aStatus) {
Maybe<LoadInfoArgs> loadInfoArgs;
MOZ_ALWAYS_SUCCEEDS(
mozilla::ipc::LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs));
Unused << SendCrossProcessRedirectDone(aStatus, loadInfoArgs);
Unused << SendCrossProcessRedirectDone(mStatus, loadInfoArgs);
return NS_OK;
}

View File

@ -1258,10 +1258,14 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvCrossProcessRedirectDone(
const nsresult& aResult,
const mozilla::Maybe<LoadInfoArgs>& aLoadInfoArgs) {
RefPtr<nsHttpChannel> chan = do_QueryObject(mChannel);
nsresult rv = NS_OK;
nsresult rv = aResult;
auto sendReply =
MakeScopeExit([&]() { FinishCrossProcessRedirect(chan, rv); });
if (NS_FAILED(rv)) {
return IPC_OK();
}
nsCOMPtr<nsILoadInfo> newLoadInfo;
rv = LoadInfoArgsToLoadInfo(aLoadInfoArgs, getter_AddRefs(newLoadInfo));
if (NS_FAILED(rv)) {