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 324465 7e1519cd5349ade03ad23a91b246ae137c9ed581
parent 324464 2b7386abfe14b66dd37391dd3752975728e40231
child 324466 5ec0f21b006c7184981a7ccf0d2a736bcbc0d47d
push id31006
push usercbook@mozilla.com
push dateTue, 29 Nov 2016 10:40:01 +0000
treeherdermozilla-central@f8107cf96144 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1319846
milestone53.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 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();