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 324463 2b7386abfe14b66dd37391dd3752975728e40231
parent 324462 ac1e6c7e2a43f970fc638802ef39fb65b138a452
child 324464 7e1519cd5349ade03ad23a91b246ae137c9ed581
push id84420
push userbkelly@mozilla.com
push dateMon, 28 Nov 2016 22:19:06 +0000
treeherdermozilla-inbound@7e1519cd5349 [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 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();
+});