Bug 1319846 - Part 3: Add a wpt test verifying Cache API can store and reproduce Response.redirect(). r=asuth, a=gchang
authorBen Kelly <ben@wanderview.com>
Mon, 28 Nov 2016 14:18:27 -0800
changeset 349397 96503957841c8c7617a416719c89a06778de396a
parent 349396 d85bdb39cf3fab0f4d7a5a50295e08b8063d14e3
child 349398 e5a46a7cd14f7cc0a99298302239a66bd1658a3c
push id10377
push userryanvm@gmail.com
push dateWed, 30 Nov 2016 03:59:25 +0000
treeherdermozilla-aurora@96503957841c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1319846
milestone52.0a2
Bug 1319846 - Part 3: Add a wpt test verifying Cache API can store and reproduce Response.redirect(). r=asuth, a=gchang
testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js
--- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js
+++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js
@@ -279,9 +279,27 @@ cache_test(function(cache) {
       cache.put(new Request(test_url),
                 new Response(test_body,
                              { headers: { VARY: 'Accept-Language,*' }})),
       new TypeError(),
       'Cache.put should reject Responses with an embedded VARY:* with a ' +
       'TypeError.');
   }, 'Cache.put with an embedded VARY:* Response');
 
+cache_test(function(cache) {
+    var url = 'foo.html';
+    var redirectURL = 'http://example.com/foo-bar.html';
+    var redirectResponse = Response.redirect(redirectURL);
+    assert_equals(redirectResponse.headers.get('Location'), redirectURL,
+                  'Response.redirect() should set Location header.');
+    return cache.put(url, redirectResponse.clone())
+      .then(function() {
+          return cache.match(url);
+        })
+      .then(function(response) {
+          assert_response_equals(response, redirectResponse,
+                                 'Redirect response is reproduced by the Cache API');
+          assert_equals(response.headers.get('Location'), redirectURL,
+                        'Location header is preserved by Cache API.');
+        });
+  }, 'Cache.put should store Response.redirect() correctly');
+
 done();