Bug 1319846 P2 Add a mochitest verifying storing a Response.redirect() works. r=asuth
authorBen Kelly <ben@wanderview.com>
Mon, 28 Nov 2016 14:18:27 -0800
changeset 324497 2b7386abfe14b66dd37391dd3752975728e40231
parent 324496 ac1e6c7e2a43f970fc638802ef39fb65b138a452
child 324498 7e1519cd5349ade03ad23a91b246ae137c9ed581
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersasuth
bugs1319846
milestone53.0a1
Bug 1319846 P2 Add a mochitest verifying storing a Response.redirect() works. r=asuth
dom/cache/test/mochitest/mochitest.ini
dom/cache/test/mochitest/test_cache_redirect.html
dom/cache/test/mochitest/test_cache_redirect.js
--- a/dom/cache/test/mochitest/mochitest.ini
+++ b/dom/cache/test/mochitest/mochitest.ini
@@ -15,16 +15,17 @@ support-files =
   test_cache_match_vary.js
   vary.sjs
   test_caches.js
   test_cache_keys.js
   test_cache_put.js
   test_cache_requestCache.js
   test_cache_delete.js
   test_cache_put_reorder.js
+  test_cache_redirect.js
   test_cache_https.js
   large_url_list.js
   empty.html
 
 [test_cache.html]
 [test_cache_add.html]
 [test_cache_match_request.html]
 [test_cache_matchAll_request.html]
@@ -32,14 +33,15 @@ support-files =
 [test_cache_match_vary.html]
 [test_caches.html]
 [test_cache_keys.html]
 [test_cache_put.html]
 [test_cache_requestCache.html]
 [test_cache_delete.html]
 [test_cache_put_reorder.html]
 [test_cache_https.html]
+[test_cache_redirect.html]
 [test_cache_restart.html]
 [test_cache_shrink.html]
 [test_cache_orphaned_cache.html]
 [test_cache_orphaned_body.html]
 [test_cache_untrusted.html]
 [test_chrome_constructor.html]
new file mode 100644
--- /dev/null
+++ b/dom/cache/test/mochitest/test_cache_redirect.html
@@ -0,0 +1,20 @@
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Validate Cache storage of redirect responses</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="driver.js"></script>
+</head>
+<body>
+<iframe id="frame"></iframe>
+<script class="testbody" type="text/javascript">
+  runTests("test_cache_redirect.js")
+    .then(function() {
+      SimpleTest.finish();
+    });
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/cache/test/mochitest/test_cache_redirect.js
@@ -0,0 +1,14 @@
+let cache;
+let url = 'foo.html';
+let redirectURL = 'http://example.com/foo-bar.html';
+caches.open('redirect-' + context).then(c => {
+  cache = c;
+  var response = Response.redirect(redirectURL);
+  is(response.headers.get('Location'), redirectURL);
+  return cache.put(url, response);
+}).then(_ => {
+  return cache.match(url);
+}).then(response => {
+  is(response.headers.get('Location'), redirectURL);
+  testDone();
+});