| OLD | NEW |
| 1 if (self.importScripts) { | 1 if (self.importScripts) { |
| 2 importScripts('/resources/testharness.js'); | 2 importScripts('/resources/testharness.js'); |
| 3 importScripts('../resources/test-helpers.js'); | 3 importScripts('../resources/test-helpers.js'); |
| 4 } | 4 } |
| 5 | 5 |
| 6 promise_test(function(t) { | 6 promise_test(function(t) { |
| 7 var cache_name = 'cache-storage/foo'; | 7 var cache_name = 'cache-storage/foo'; |
| 8 return self.caches.delete(cache_name) | 8 return self.caches.delete(cache_name) |
| 9 .then(function() { | 9 .then(function() { |
| 10 return self.caches.open(cache_name); | 10 return self.caches.open(cache_name); |
| 11 }) | 11 }) |
| 12 .then(function(cache) { | 12 .then(function(cache) { |
| 13 assert_true(cache instanceof Cache, | 13 assert_true(cache instanceof Cache, |
| 14 'CacheStorage.open should return a Cache.'); | 14 'CacheStorage.open should return a Cache.'); |
| 15 }); | 15 }); |
| 16 }, 'CacheStorage.open'); | 16 }, 'CacheStorage.open'); |
| 17 | 17 |
| 18 promise_test(function(t) { | 18 promise_test(function(t) { |
| 19 var cache_name = 'cache-storage/bar'; |
| 20 var first_cache = null; |
| 21 var second_cache = null; |
| 22 return self.caches.open(cache_name) |
| 23 .then(function(cache) { |
| 24 first_cache = cache; |
| 25 return self.caches.delete(cache_name); |
| 26 }) |
| 27 .then(function() { |
| 28 return first_cache.add('../resources/simple.txt'); |
| 29 }) |
| 30 .then(function() { |
| 31 return self.caches.keys(); |
| 32 }) |
| 33 .then(function(cache_names) { |
| 34 assert_equals(cache_names.indexOf(cache_name), -1); |
| 35 return self.caches.open(cache_name); |
| 36 }) |
| 37 .then(function(cache) { |
| 38 second_cache = cache; |
| 39 return second_cache.keys(); |
| 40 }) |
| 41 .then(function(keys) { |
| 42 assert_equals(keys.length, 0); |
| 43 return first_cache.keys(); |
| 44 }) |
| 45 .then(function(keys) { |
| 46 assert_equals(keys.length, 1); |
| 47 // Clean up |
| 48 return self.caches.delete(cache_name); |
| 49 }) |
| 50 }, 'CacheStorage.delete dooms'); |
| 51 |
| 52 promise_test(function(t) { |
| 19 // Note that this test may collide with other tests running in the same | 53 // Note that this test may collide with other tests running in the same |
| 20 // origin that also uses an empty cache name. | 54 // origin that also uses an empty cache name. |
| 21 var cache_name = ''; | 55 var cache_name = ''; |
| 22 return self.caches.delete(cache_name) | 56 return self.caches.delete(cache_name) |
| 23 .then(function() { | 57 .then(function() { |
| 24 return self.caches.open(cache_name); | 58 return self.caches.open(cache_name); |
| 25 }) | 59 }) |
| 26 .then(function(cache) { | 60 .then(function(cache) { |
| 27 assert_true(cache instanceof Cache, | 61 assert_true(cache instanceof Cache, |
| 28 'CacheStorage.open should accept an empty name.'); | 62 'CacheStorage.open should accept an empty name.'); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 'CacheStorage names should be not be converted.'); | 222 'CacheStorage names should be not be converted.'); |
| 189 }) | 223 }) |
| 190 .then(function() { return self.caches.has(converted_name); }) | 224 .then(function() { return self.caches.has(converted_name); }) |
| 191 .then(function(cache_exists) { | 225 .then(function(cache_exists) { |
| 192 assert_false(cache_exists, | 226 assert_false(cache_exists, |
| 193 'CacheStorage names should be not be converted.'); | 227 'CacheStorage names should be not be converted.'); |
| 194 }); | 228 }); |
| 195 }, 'CacheStorage names are DOMStrings not USVStrings'); | 229 }, 'CacheStorage names are DOMStrings not USVStrings'); |
| 196 | 230 |
| 197 done(); | 231 done(); |
| OLD | NEW |