Bug 1271905 P2 Test Cache.put() using a Response for a shutdown origin. r=asuth a=ritu
authorBen Kelly <ben@wanderview.com>
Fri, 13 May 2016 11:44:38 -0700
changeset 371630 805051b9a46259319d5c56424cb5249efc811363
parent 371629 d768e95103ff967c108496bc035b3be5fbef50b8
child 371631 457c492187c7efca1a56cc5daee4834567116c06
push id19358
push usercliu@mozilla.com
push dateThu, 26 May 2016 21:42:05 +0000
reviewersasuth, ritu
bugs1271905
milestone48.0a2
Bug 1271905 P2 Test Cache.put() using a Response for a shutdown origin. r=asuth a=ritu
dom/cache/test/mochitest/test_cache_orphaned_body.html
--- a/dom/cache/test/mochitest/test_cache_orphaned_body.html
+++ b/dom/cache/test/mochitest/test_cache_orphaned_body.html
@@ -158,14 +158,30 @@ SpecialPowers.pushPrefEnv({
   }).then(function() {
     return storageUsage();
   }).then(function(usage) {
     endUsage = usage;
     dump("### ### initial:" + initialUsage + ", full:" + fullUsage +
          ", end:" + endUsage + "\n");
     ok(endUsage < fullUsage, 'disk usage should have shrank');
     is(endUsage, initialUsage, 'disk usage should return to original');
+  })
+
+  // Verify that the stale, orphaned response cannot be put back into
+  // the cache.
+  .then(function() {
+    ok(!response.bodyUsed, 'response body should not be considered used');
+    return cache.put(url, response).then(function() {
+        ok(false, 'Should not be able to store stale orphaned body.');
+      }).catch(function(e) {
+        is(e.name, 'TypeError', 'storing a stale orphaned body should throw TypeError');
+      });
+  }).then(function() {
+    ok(response.bodyUsed, 'attempting to store response should mark body used');
+  })
+
+  .then(function() {
     SimpleTest.finish();
   });
 });
 </script>
 </body>
 </html>