Bug 1319846 - Part 2: Add a mochitest verifying storing a Response.redirect() works. r=asuth, a=gchang
authorBen Kelly <ben@wanderview.com>
Mon, 28 Nov 2016 14:18:27 -0800
changeset 349396 d85bdb39cf3fab0f4d7a5a50295e08b8063d14e3
parent 349395 e8ad14b973ac729dbc57869f1b690f6b78713242
child 349397 96503957841c8c7617a416719c89a06778de396a
push id10377
push userryanvm@gmail.com
push dateWed, 30 Nov 2016 03:59:25 +0000
treeherdermozilla-aurora@96503957841c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1319846
milestone52.0a2
Bug 1319846 - Part 2: Add a mochitest verifying storing a Response.redirect() works. r=asuth, a=gchang
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();
+});