Bug 1263469 P2 Validate FetchEvent.request.cache in refresh mochitest. r=ehsan
authorBen Kelly <ben@wanderview.com>
Fri, 15 Apr 2016 11:15:58 -0700
changeset 331378 a908bea60e6764b675a750b41bd6551af2eeaf69
parent 331377 c5ea46c9e9e9109706e54554f12bef46e0a2157f
child 331379 afd29752788807ef5cb8917ba033eb7f00631039
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1263469
milestone48.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 1263469 P2 Validate FetchEvent.request.cache in refresh mochitest. r=ehsan
dom/workers/test/serviceworkers/force_refresh_worker.js
--- a/dom/workers/test/serviceworkers/force_refresh_worker.js
+++ b/dom/workers/test/serviceworkers/force_refresh_worker.js
@@ -14,12 +14,20 @@ self.addEventListener('install', functio
   );
 });
 
 self.addEventListener('fetch', function (event) {
   event.respondWith(
     caches.open(name).then(function(cache) {
       return cache.match(event.request);
     }).then(function(response) {
+      // If this is one of our primary cached responses, then the window
+      // must have generated the request via a normal window reload.  That
+      // should be detectable in the event.request.cache attribute.
+      if (response && event.request.cache !== 'no-cache') {
+        dump('### ### FetchEvent.request.cache is "' + event.request.cache +
+             '" instead of expected "no-cache"\n');
+        return Response.error();
+      }
       return response || fetch(event.request);
     })
   );
 });