test_cache_requestCache.js 1006 B

12345678910111213141516171819202122232425262728
  1. var name = "requestCache" + context;
  2. var c;
  3. var reqWithoutCache = new Request("//mochi.test:8888/?noCache" + context);
  4. var reqWithCache = new Request("//mochi.test:8888/?withCache" + context,
  5. {cache: "force-cache"});
  6. // Sanity check
  7. is(reqWithoutCache.cache, "default", "Correct default value");
  8. is(reqWithCache.cache, "force-cache", "Correct value set by the ctor");
  9. caches.open(name).then(function(cache) {
  10. c = cache;
  11. return c.addAll([reqWithoutCache, reqWithCache]);
  12. }).then(function() {
  13. return c.keys();
  14. }).then(function(keys) {
  15. is(keys.length, 2, "Correct number of requests");
  16. is(keys[0].url, reqWithoutCache.url, "Correct URL");
  17. is(keys[0].cache, reqWithoutCache.cache, "Correct cache attribute");
  18. is(keys[1].url, reqWithCache.url, "Correct URL");
  19. is(keys[1].cache, reqWithCache.cache, "Correct cache attribute");
  20. return caches.delete(name);
  21. }).then(function(deleted) {
  22. ok(deleted, "The cache should be successfully deleted");
  23. testDone();
  24. });