From 8eea6736f43850b39c4eb0c153f62a999b752841 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Mon, 28 Nov 2016 14:18:27 -0800 Subject: [PATCH] Bug 1319846 P3 Add a wpt test verifying Cache API can store and reproduce Response.redirect(). r=asuth --- .../cache-storage/script-tests/cache-put.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git 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 index 8dbaf9789d5a..bcc8541ad406 100644 --- 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 @@ -284,4 +284,22 @@ cache_test(function(cache) { '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();