test_cache_https.js 852 B

1234567891011121314151617181920212223242526272829303132
  1. var cache = null;
  2. var name = 'https_' + context;
  3. var urlBase = 'https://example.com/tests/dom/cache/test/mochitest';
  4. var url1 = urlBase + '/test_cache.js';
  5. var url2 = urlBase + '/test_cache_add.js';
  6. function addOpaque(cache, url) {
  7. return fetch(new Request(url, { mode: 'no-cors' })).then(function(response) {
  8. return cache.put(url, response);
  9. });
  10. }
  11. caches.open(name).then(function(c) {
  12. cache = c;
  13. return Promise.all([
  14. addOpaque(cache, url1),
  15. addOpaque(cache, url2)
  16. ]);
  17. }).then(function() {
  18. return cache.delete(url1);
  19. }).then(function(result) {
  20. ok(result, 'Cache entry should be deleted');
  21. return cache.delete(url2);
  22. }).then(function(result) {
  23. ok(result, 'Cache entry should be deleted');
  24. cache = null;
  25. return caches.delete(name);
  26. }).then(function(result) {
  27. ok(result, 'Cache should be deleted');
  28. testDone();
  29. });