Backed out changeset 82cd6a486698 (
bug 1233245) for fetch-request-redirect.https.html failures CLOSED TREE
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -2007,16 +2007,34 @@ nsHttpChannel::StartRedirectChannelToURI
NS_ENSURE_SUCCESS(rv, rv);
rv = SetupReplacementChannel(upgradedURI, newChannel, true, flags);
NS_ENSURE_SUCCESS(rv, rv);
// 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);
+ }
+ }
+
PushRedirectAsyncFunc(
&nsHttpChannel::ContinueAsyncRedirectChannelToURI);
rv = gHttpHandler->AsyncOnChannelRedirect(this, newChannel, flags);
if (NS_SUCCEEDED(rv))
rv = WaitForRedirectCallback();
if (NS_FAILED(rv)) {
@@ -4582,34 +4600,16 @@ nsHttpChannel::SetupReplacementChannel(n
nsCOMPtr<nsIResumableChannel> resumableChannel(do_QueryInterface(newChannel));
if (!resumableChannel) {
NS_WARNING("Got asked to resume, but redirected to non-resumable channel!");
return NS_ERROR_NOT_RESUMABLE;
}
resumableChannel->ResumeAt(mStartPos, mEntityID);
}
- if (!(redirectFlags & 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(newChannel);
- if (httpRedirect) {
- httpRedirect->ForceIntercepted(mInterceptionID);
- }
- } else {
- 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;
}
nsresult
nsHttpChannel::AsyncProcessRedirection(uint32_t redirectType)
{
LOG(("nsHttpChannel::AsyncProcessRedirection [this=%p type=%u]\n",
this, redirectType));
--- a/testing/web-platform/mozilla/tests/service-workers/service-worker/navigation-redirect.https.html
+++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/navigation-redirect.https.html
@@ -145,25 +145,25 @@ function get_intercepted_urls(worker) {
}
// Normal redirect.
promise_test(function(t) {
return setup_environment(t).then(function() {
return test_redirect(
OUT_SCOPE + 'url=' + encodeURIComponent(SCOPE1),
SCOPE1,
- [[], [], []]);
+ [[SCOPE1], [], []]);
});
}, 'Normal redirect to same-origin scope.');
promise_test(function(t) {
return setup_environment(t).then(function() {
return test_redirect(
OUT_SCOPE + 'url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE),
OTHER_ORIGIN_SCOPE,
- [[], [], []]);
+ [[], [], [OTHER_ORIGIN_SCOPE]]);
});
}, 'Normal redirect to other-origin scope.');
// SW fallbacked redirect. SW doesn't handle the fetch request.
promise_test(function(t) {
return setup_environment(t).then(function() {
return test_redirect(
SCOPE1 + 'url=' + encodeURIComponent(OUT_SCOPE),