Bug 1233245 - Propagate the interception information in the non-e10s case for all HTTP redirects, not just the internal ones; r=jdm,bkelly
☠☠ backed out by 1c8ba5322a17 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 16 Dec 2015 17:53:53 -0500
changeset 276822 82cd6a486698b4191411ba5de448c1bca518a699
parent 276821 e6523d21523f37fc56bcf0e27b269657f90c7bd7
child 276823 40bdbd4eff2a0b6afda1ac24075b2277c38ed32d
push id69297
push usereakhgari@mozilla.com
push dateThu, 17 Dec 2015 22:32:54 +0000
treeherdermozilla-inbound@82cd6a486698 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm, bkelly
bugs1233245
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1233245 - Propagate the interception information in the non-e10s case for all HTTP redirects, not just the internal ones; r=jdm,bkelly 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.
netwerk/protocol/http/nsHttpChannel.cpp
testing/web-platform/mozilla/tests/service-workers/service-worker/navigation-redirect.https.html
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -2007,34 +2007,16 @@ 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)) {
@@ -4600,16 +4582,34 @@ 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),