Bug 1170795 - Ignore redirect errors for synthesized cache entries. r=mayhemer
☠☠ backed out by 809818706503 ☠ ☠
authorJosh Matthews <josh@joshmatthews.net>
Thu, 04 Jun 2015 10:06:33 -0400
changeset 247148 e95a9e8e76508c6fc43aa52171fd57805240a26b
parent 247147 96c7f848202925ebcc4a8ec86daf4180581fb22a
child 247149 7a4371bbe6382e017b8b9b0dffb7bc85b5c0bd0d
push id60615
push userjosh@joshmatthews.net
push dateThu, 04 Jun 2015 14:14:02 +0000
treeherdermozilla-inbound@e95a9e8e7650 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1170795
milestone41.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 1170795 - Ignore redirect errors for synthesized cache entries. r=mayhemer
dom/workers/test/serviceworkers/fetch/fetch_tests.js
dom/workers/test/serviceworkers/fetch_event_worker.js
netwerk/protocol/http/nsHttpChannel.cpp
--- a/dom/workers/test/serviceworkers/fetch/fetch_tests.js
+++ b/dom/workers/test/serviceworkers/fetch/fetch_tests.js
@@ -34,16 +34,22 @@ fetchXHR('test-respondwith-response.txt'
 });
 
 fetchXHR('synthesized-404.txt', function(xhr) {
   my_ok(xhr.status == 404, "load should 404");
   my_ok(xhr.responseText == "synthesized response body", "404 load should have synthesized response");
   finish();
 });
 
+fetchXHR('synthesized-308.txt', function(xhr) {
+  my_ok(xhr.status == 308, "load should return 308");
+  my_ok(xhr.responseText == "synthesized response body", "308 load should have synthesized response");
+  finish();
+});
+
 fetchXHR('synthesized-headers.txt', function(xhr) {
   my_ok(xhr.status == 200, "load should be successful");
   my_ok(xhr.getResponseHeader("X-Custom-Greeting") === "Hello", "custom header should be set");
   my_ok(xhr.responseText == "synthesized response body", "custom header load should have synthesized response");
   finish();
 });
 
 fetchXHR('synthesized-redirect-real-file.txt', function(xhr) {
--- a/dom/workers/test/serviceworkers/fetch_event_worker.js
+++ b/dom/workers/test/serviceworkers/fetch_event_worker.js
@@ -8,16 +8,22 @@ onfetch = function(ev) {
   }
 
   else if (ev.request.url.includes("synthesized-404.txt")) {
     ev.respondWith(Promise.resolve(
       new Response("synthesized response body", { status: 404 })
     ));
   }
 
+  else if (ev.request.url.includes("synthesized-308.txt")) {
+    ev.respondWith(Promise.resolve(
+      new Response("synthesized response body", { status: 308 })
+    ));
+  }
+
   else if (ev.request.url.includes("synthesized-headers.txt")) {
     ev.respondWith(Promise.resolve(
       new Response("synthesized response body", {
         headers: {
           "X-Custom-Greeting": "Hello"
         }
       })
     ));
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -2946,18 +2946,21 @@ nsHttpChannel::OnCacheEntryCheck(nsICach
     rv = mCachedResponseHead->Parse((char *) buf.get());
     NS_ENSURE_SUCCESS(rv, rv);
     buf.Adopt(0);
 
     bool isCachedRedirect = WillRedirect(mCachedResponseHead);
 
     // Do not return 304 responses from the cache, and also do not return
     // any other non-redirect 3xx responses from the cache (see bug 759043).
+    // However, if this is a synthesized cache entry we don't care what the
+    // content is and will return it regardless.
     NS_ENSURE_TRUE((mCachedResponseHead->Status() / 100 != 3) ||
-                   isCachedRedirect, NS_ERROR_ABORT);
+                   isCachedRedirect ||
+                   mInterceptCache == INTERCEPTED, NS_ERROR_ABORT);
 
     // Don't bother to validate items that are read-only,
     // unless they are read-only because of INHIBIT_CACHING or because
     // we're updating the offline cache.
     // Don't bother to validate if this is a fallback entry.
     if (!mApplicationCacheForWrite &&
         (appCache ||
          (mCacheEntryIsReadOnly && !(mLoadFlags & nsIRequest::INHIBIT_CACHING)) ||