Chromium Code Reviews| 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); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 promise_test(function(t) { | 196 promise_test(function(t) { |
| 197 return self.caches.delete('cheezburger') | 197 return self.caches.delete('cheezburger') |
| 198 .then(function(result) { | 198 .then(function(result) { |
| 199 assert_false(result, | 199 assert_false(result, |
| 200 'CacheStorage.delete should return false for a ' + | 200 'CacheStorage.delete should return false for a ' + |
| 201 'nonexistent cache.'); | 201 'nonexistent cache.'); |
| 202 }); | 202 }); |
| 203 }, 'CacheStorage.delete with nonexistent cache'); | 203 }, 'CacheStorage.delete with nonexistent cache'); |
| 204 | 204 |
| 205 promise_test(function(t) { | 205 promise_test(function(t) { |
| 206 var bad_name = 'unpaired\uD800'; | 206 var unpaired_name = 'unpaired\uD800'; |
| 207 var converted_name = 'unpaired\uFFFD'; // Don't create cache with this name. | 207 var converted_name = 'unpaired\uFFFD'; |
| 208 return self.caches.has(converted_name) | 208 |
| 209 // The test assumes that a cache with converted_name does not | |
| 210 // exist, but if the implementation fails the test then such | |
| 211 // a cache will be created. Start off in a fresh state by | |
| 212 // deleting all caches. | |
| 213 return delete_all_caches() | |
|
jkarlin
2016/11/22 18:20:40
Why not have promise_test run delete_all_caches at
jsbell
2016/11/22 18:34:14
promise_test is generic (part of testharness.js);
| |
| 214 .then(function() { | |
| 215 return self.caches.has(converted_name); | |
| 216 }) | |
| 209 .then(function(cache_exists) { | 217 .then(function(cache_exists) { |
| 210 assert_false(cache_exists, | 218 assert_false(cache_exists, |
| 211 'Test setup failure: cache should not exist'); | 219 'Test setup failure: cache should not exist'); |
| 212 }) | 220 }) |
| 213 .then(function() { return self.caches.open(bad_name); }) | 221 .then(function() { return self.caches.open(unpaired_name); }) |
| 214 .then(function() { return self.caches.keys(); }) | 222 .then(function() { return self.caches.keys(); }) |
| 215 .then(function(keys) { | 223 .then(function(keys) { |
| 216 assert_true(keys.indexOf(bad_name) !== -1, | 224 assert_true(keys.indexOf(unpaired_name) !== -1, |
| 217 'keys should include cache with bad name'); | 225 'keys should include cache with bad name'); |
| 218 }) | 226 }) |
| 219 .then(function() { return self.caches.has(bad_name); }) | 227 .then(function() { return self.caches.has(unpaired_name); }) |
| 220 .then(function(cache_exists) { | 228 .then(function(cache_exists) { |
| 221 assert_true(cache_exists, | 229 assert_true(cache_exists, |
| 222 'CacheStorage names should be not be converted.'); | 230 'CacheStorage names should be not be converted.'); |
| 223 }) | 231 }) |
| 224 .then(function() { return self.caches.has(converted_name); }) | 232 .then(function() { return self.caches.has(converted_name); }) |
| 225 .then(function(cache_exists) { | 233 .then(function(cache_exists) { |
| 226 assert_false(cache_exists, | 234 assert_false(cache_exists, |
| 227 'CacheStorage names should be not be converted.'); | 235 'CacheStorage names should be not be converted.'); |
| 228 }); | 236 }); |
| 229 }, 'CacheStorage names are DOMStrings not USVStrings'); | 237 }, 'CacheStorage names are DOMStrings not USVStrings'); |
| 230 | 238 |
| 231 done(); | 239 done(); |
| OLD | NEW |