Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 importScripts('worker-test-harness.js'); | |
| 2 | |
| 3 promise_test(function(test) { | |
| 4 return caches.create('foo') | |
| 5 .then(test.step_func(function(cache) { | |
| 6 assert_true(cache, | |
| 7 'CacheStorage.create should return a valid Cache.'); | |
| 8 assert_true(cache instanceof Cache, | |
| 9 'CacheStorage.create should return a valid Cache.'); | |
| 10 })); | |
| 11 }, 'CacheStorage.create'); | |
| 12 | |
| 13 promise_test(function(test) { | |
| 14 return caches.create() | |
| 15 // FIXME: Define the behavior for .create() with an empty or | |
| 16 // non-string cache name. | |
| 17 .then(test.unreached_func('CacheStorage.create should reject ' + | |
|
jsbell
2014/08/01 00:09:11
You may be able to avoid splitting the string in s
asanka
2014/08/01 06:03:21
Done.
| |
| 18 'invalid name.'), | |
| 19 function() {}); | |
| 20 }, 'CacheStorage.create with invalid cache name'); | |
| 21 | |
| 22 promise_test(function(test) { | |
| 23 return caches.create('bar') | |
| 24 .then(test.step_func(function() { return caches.has('bar'); })) | |
| 25 .then(test.step_func(function(result) { | |
| 26 assert_true(result, | |
| 27 'CacheStorage.has should return true for ' + | |
| 28 'existing cache'); | |
| 29 })); | |
| 30 }, 'CacheStorage.has with existing cache'); | |
| 31 | |
| 32 promise_test(function(test) { | |
| 33 return caches.has('cheezburger') | |
| 34 .then(test.step_func(function(result) { | |
| 35 assert_false(result, | |
| 36 'CacheStorage.has should return false for ' + | |
| 37 'non-existent cache'); | |
| 38 })); | |
| 39 }, 'CacheStorage.has with non-existent cache'); | |
| 40 | |
| 41 promise_test(function(test) { | |
| 42 return caches.has() | |
| 43 // FIXME: Define the behavior for .has() with an invalid or undefined | |
| 44 // name. Perhaps it should reject instead of returning false. | |
| 45 .then(test.step_func(function(result) { | |
| 46 // FIXME: Could fail due to the cache creation with an undefined name | |
| 47 // above. Tests shouldn't interact since these are all async_tests. | |
| 48 assert_false(result, | |
| 49 'CacheStorage.has should return false for invalid ' + | |
| 50 'cache name.'); | |
| 51 })); | |
| 52 }, 'CacheStorage.has with invalid cache name'); | |
| 53 | |
| 54 promise_test(function(test) { | |
| 55 var cache_name = 'to-be-deleted'; | |
| 56 | |
| 57 return caches.create(cache_name) | |
| 58 .then(function() { return caches.delete(cache_name); }) | |
| 59 .then(function() {}, | |
| 60 test.unreached_func('CacheStorage.delete should not reject ' + | |
| 61 'existing cache')) | |
| 62 | |
| 63 .then(function() { return caches.has(cache_name); }) | |
| 64 .then(test.step_func(function(cache_exists) { | |
| 65 assert_false( | |
| 66 cache_exists, | |
| 67 'CacheStorage.has should not return true after ' + | |
| 68 'fulfilment of CacheStorage.delete promise'); | |
| 69 })); | |
| 70 }, 'CacheStorage.delete with existing cache'); | |
| 71 | |
| 72 promise_test(function(test) { | |
| 73 return caches.delete('cheezburger') | |
| 74 .then(test.unreached_func('CacheStorage.delete should not fulfil ' + | |
| 75 'promise to delete non-existent cache.'), | |
| 76 function() {}); | |
| 77 }, 'CacheStorage.delete with non-existent cache'); | |
| 78 | |
| 79 // FIXME: Define and test behavior for invalid cache name with delete(). | |
| OLD | NEW |