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 356799 e261a8b9adaa9f9436818263a30db6f7b25e921b
parent 356798 4847bb920028abc424b6bb93b08f5cf32d58470d
child 356800 34c73c520f938e66c312dfe83bdd944c6363facc
push id6635
push userryanvm@gmail.com
push dateWed, 30 Nov 2016 04:50:15 +0000
treeherdermozilla-beta@34c73c520f93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, gchang
bugs1319846
milestone51.0
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
   app/*
 
 [test_cache.html]
 [test_cache_add.html]
 [test_cache_match_request.html]
@@ -34,16 +35,17 @@ support-files =
 [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]
   skip-if = buildapp == 'b2g' # bug 1162353
+[test_cache_redirect.html]
 [test_cache_restart.html]
 [test_cache_shrink.html]
 [test_cache_clear_on_app_uninstall.html]
   skip-if = true || e10s # bug 1178685 ### Bug 1255339: blacklist because no more mozApps
 [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();
+});