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, but does not delete immediately'); |
| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 'CacheStorage names should be not be converted.'); | 230 'CacheStorage names should be not be converted.'); |
197 }) | 231 }) |
198 .then(function() { return self.caches.has(converted_name); }) | 232 .then(function() { return self.caches.has(converted_name); }) |
199 .then(function(cache_exists) { | 233 .then(function(cache_exists) { |
200 assert_false(cache_exists, | 234 assert_false(cache_exists, |
201 'CacheStorage names should be not be converted.'); | 235 'CacheStorage names should be not be converted.'); |
202 }); | 236 }); |
203 }, 'CacheStorage names are DOMStrings not USVStrings'); | 237 }, 'CacheStorage names are DOMStrings not USVStrings'); |
204 | 238 |
205 done(); | 239 done(); |
OLD | NEW |