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 356800 34c73c520f938e66c312dfe83bdd944c6363facc
parent 356799 e261a8b9adaa9f9436818263a30db6f7b25e921b
child 356801 a1dbca5c927bcb625de7e8969a3a6e1cda83a63b
push id6635
push userryanvm@gmail.com
push dateWed, 30 Nov 2016 04:50:15 +0000
treeherdermozilla-beta@34c73c520f93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1319846
milestone51.0
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();