Commit 3806e267 authored by Ben Kelly's avatar Ben Kelly
Browse files

Bug 1319846 P2 Add a mochitest verifying storing a Response.redirect() works. r=asuth

parent 235f44a1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ support-files =
  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
@@ -37,6 +38,7 @@ support-files =
[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]
+20 −0
Original line number Diff line number Diff line
<!-- 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>
+14 −0
Original line number Diff line number Diff line
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();
});