Bug 1319846 P3 Add a wpt test verifying Cache API can store and reproduce Response.redirect(). r=asuth
authorBen Kelly <ben@wanderview.com>
Mon, 28 Nov 2016 14:18:27 -0800
changeset 324498 7e1519cd5349ade03ad23a91b246ae137c9ed581
parent 324497 2b7386abfe14b66dd37391dd3752975728e40231
child 324499 5ec0f21b006c7184981a7ccf0d2a736bcbc0d47d
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersasuth
bugs1319846
milestone53.0a1
Bug 1319846 P3 Add a wpt test verifying Cache API can store and reproduce Response.redirect(). r=asuth
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();