| OLD | NEW |
| 1 if (self.importScripts) { | 1 if (self.importScripts) { |
| 2 importScripts('/resources/testharness.js'); | 2 importScripts('/resources/testharness.js'); |
| 3 importScripts('/resources/testharness-helpers.js'); | 3 importScripts('/resources/testharness-helpers.js'); |
| 4 importScripts('../resources/test-helpers.js'); | 4 importScripts('../resources/test-helpers.js'); |
| 5 } | 5 } |
| 6 | 6 |
| 7 promise_test(function(t) { | 7 promise_test(function(t) { |
| 8 var cache_name = 'cache-storage/foo'; | 8 var cache_name = 'cache-storage/foo'; |
| 9 return self.caches.delete(cache_name) | 9 return self.caches.delete(cache_name) |
| 10 .then(function() { | 10 .then(function() { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 var cache_name = 'cache-storage/open'; | 108 var cache_name = 'cache-storage/open'; |
| 109 var cache; | 109 var cache; |
| 110 return self.caches.delete(cache_name) | 110 return self.caches.delete(cache_name) |
| 111 .then(function() { | 111 .then(function() { |
| 112 return self.caches.open(cache_name); | 112 return self.caches.open(cache_name); |
| 113 }) | 113 }) |
| 114 .then(function(result) { | 114 .then(function(result) { |
| 115 cache = result; | 115 cache = result; |
| 116 }) | 116 }) |
| 117 .then(function() { | 117 .then(function() { |
| 118 return cache.add('../resources/simple.txt'); |
| 119 }) |
| 120 .then(function() { |
| 118 return self.caches.open(cache_name); | 121 return self.caches.open(cache_name); |
| 119 }) | 122 }) |
| 120 .then(function(result) { | 123 .then(function(result) { |
| 121 assert_equals(result, cache, | 124 assert_true(result instanceof Cache, |
| 122 'CacheStorage.open should return the named Cache ' + | 125 'CacheStorage.open should return a Cache object'); |
| 123 'object if it exists.'); | 126 assert_not_equals(result, cache, |
| 127 'CacheStorage.open should return a new Cache ' + |
| 128 'object each time its called.'); |
| 129 return Promise.all([cache.keys(), result.keys()]); |
| 124 }) | 130 }) |
| 125 .then(function() { | 131 .then(function(results) { |
| 126 return self.caches.open(cache_name); | 132 var expected_urls = results[0].map(function(r) { return r.url }); |
| 127 }) | 133 var actual_urls = results[1].map(function(r) { return r.url }); |
| 128 .then(function(result) { | 134 assert_array_equals(actual_urls, expected_urls, |
| 129 assert_equals(result, cache, | 135 'CacheStorage.open should return a new Cache ' + |
| 130 'CacheStorage.open should return the same ' + | 136 'object for the same backing store.'); |
| 131 'instance of an existing Cache object.'); | |
| 132 }); | 137 }); |
| 133 }, 'CacheStorage.open with existing cache'); | 138 }, 'CacheStorage.open with existing cache'); |
| 134 | 139 |
| 135 promise_test(function(t) { | 140 promise_test(function(t) { |
| 136 var cache_name = 'cache-storage/delete'; | 141 var cache_name = 'cache-storage/delete'; |
| 137 | 142 |
| 138 return self.caches.delete(cache_name) | 143 return self.caches.delete(cache_name) |
| 139 .then(function() { | 144 .then(function() { |
| 140 return self.caches.open(cache_name); | 145 return self.caches.open(cache_name); |
| 141 }) | 146 }) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 'CacheStorage names should be not be converted.'); | 188 'CacheStorage names should be not be converted.'); |
| 184 }) | 189 }) |
| 185 .then(function() { return self.caches.has(converted_name); }) | 190 .then(function() { return self.caches.has(converted_name); }) |
| 186 .then(function(cache_exists) { | 191 .then(function(cache_exists) { |
| 187 assert_false(cache_exists, | 192 assert_false(cache_exists, |
| 188 'CacheStorage names should be not be converted.'); | 193 'CacheStorage names should be not be converted.'); |
| 189 }); | 194 }); |
| 190 }, 'CacheStorage names are DOMStrings not USVStrings'); | 195 }, 'CacheStorage names are DOMStrings not USVStrings'); |
| 191 | 196 |
| 192 done(); | 197 done(); |
| OLD | NEW |