Bug 1233245 - Propagate the interception information in the non-e10s case for all HTTP redirects, not just the internal ones; r=jdm

Doing this work in StartRedirectChannelToURI() was causing us to not set
the bypass service worker flag properly in the case of real HTTP redirects.
This patch also fixes the incorrect test expectation value.
This commit is contained in:
Ehsan Akhgari 2015-12-30 18:25:48 -05:00
parent 58e5906185
commit 0de497f00c
2 changed files with 20 additions and 17 deletions

View File

@ -2012,21 +2012,12 @@ nsHttpChannel::StartRedirectChannelToURI(nsIURI *upgradedURI, uint32_t flags)
// Inform consumers about this fake redirect
mRedirectChannel = newChannel;
if (!(flags & nsIChannelEventSink::REDIRECT_STS_UPGRADE)) {
// Ensure that internally-redirected channels cannot be intercepted, which would look
// like two separate requests to the nsINetworkInterceptController.
if (mInterceptCache == INTERCEPTED) {
nsCOMPtr<nsIHttpChannelInternal> httpRedirect = do_QueryInterface(mRedirectChannel);
if (httpRedirect) {
httpRedirect->ForceIntercepted(mInterceptionID);
}
} else {
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
rv = mRedirectChannel->GetLoadFlags(&loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
rv = mRedirectChannel->SetLoadFlags(loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
if (!(flags & nsIChannelEventSink::REDIRECT_STS_UPGRADE) &&
mInterceptCache == INTERCEPTED) {
// Mark the channel as intercepted in order to propagate the response URL.
nsCOMPtr<nsIHttpChannelInternal> httpRedirect = do_QueryInterface(mRedirectChannel);
if (httpRedirect) {
httpRedirect->ForceIntercepted(mInterceptionID);
}
}
@ -4605,6 +4596,18 @@ nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
resumableChannel->ResumeAt(mStartPos, mEntityID);
}
if (!(redirectFlags & nsIChannelEventSink::REDIRECT_STS_UPGRADE) &&
mInterceptCache != INTERCEPTED) {
// Ensure that internally-redirected channels cannot be intercepted, which would look
// like two separate requests to the nsINetworkInterceptController.
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
rv = newChannel->GetLoadFlags(&loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
rv = newChannel->SetLoadFlags(loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}

View File

@ -150,7 +150,7 @@ promise_test(function(t) {
return test_redirect(
OUT_SCOPE + 'url=' + encodeURIComponent(SCOPE1),
SCOPE1,
[[SCOPE1], [], []]);
[[], [], []]);
});
}, 'Normal redirect to same-origin scope.');
promise_test(function(t) {
@ -158,7 +158,7 @@ promise_test(function(t) {
return test_redirect(
OUT_SCOPE + 'url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE),
OTHER_ORIGIN_SCOPE,
[[], [], [OTHER_ORIGIN_SCOPE]]);
[[], [], []]);
});
}, 'Normal redirect to other-origin scope.');