| OLD | NEW |
| 1 importScripts('worker-testharness.js'); | 1 importScripts('worker-testharness.js'); |
| 2 importScripts('/resources/testharness-helpers.js'); | 2 importScripts('/resources/testharness-helpers.js'); |
| 3 | 3 |
| 4 var test_url = 'https://example.com/foo'; | 4 var test_url = 'https://example.com/foo'; |
| 5 | 5 |
| 6 // Construct a generic Request object. The URL is |test_url|. All other fields | 6 // Construct a generic Request object. The URL is |test_url|. All other fields |
| 7 // are defaults. | 7 // are defaults. |
| 8 function new_test_request() { | 8 function new_test_request() { |
| 9 return new Request(test_url); | 9 return new Request(test_url); |
| 10 } | 10 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 cache_test(function(cache) { | 107 cache_test(function(cache) { |
| 108 return Promise.all(Object.keys(cache_entries).map(function(k) { | 108 return Promise.all(Object.keys(cache_entries).map(function(k) { |
| 109 return cache.put(cache_entries[k].request.clone(), | 109 return cache.put(cache_entries[k].request.clone(), |
| 110 cache_entries[k].response.clone()); | 110 cache_entries[k].response.clone()); |
| 111 })) | 111 })) |
| 112 .then(function() { | 112 .then(function() { |
| 113 return test_function(cache); | 113 return test_function(cache); |
| 114 }); | 114 }); |
| 115 }, description); | 115 }, description); |
| 116 } | 116 } |
| 117 | |
| 118 // Note that these tests don't exercise the full gamut of CacheQueryOptions. | |
| 119 // That's left for the Cache.match() and Cache.matchAll() tests. The objective | |
| 120 // is to test that CacheQueryOptions, if specified, are used. | |
| 121 | |
| 122 prepopulated_cache_test(function(cache) { | |
| 123 return cache.delete('http://example.com/a', { prefixMatch: true }) | |
| 124 .then(function(result) { | |
| 125 assert_true(result, | |
| 126 'Cache.delete should resolve with "true" if an entry ' + | |
| 127 'was successfully deleted.'); | |
| 128 }) | |
| 129 .then(function() { | |
| 130 return Promise.all( | |
| 131 [].concat( | |
| 132 // The entries 'a' and 'a_with_query' should have been deleted. | |
| 133 ['a', 'a_with_query'].map(function(k) { | |
| 134 return assert_promise_rejects( | |
| 135 cache.match(cache_entries[k].request.url), | |
| 136 'NotFoundError', | |
| 137 'Cache.delete should respect "prefixMatch" option.'); | |
| 138 }), | |
| 139 // The entry 'b' should still be in the cache. | |
| 140 cache.match(cache_entries.b.request.url) | |
| 141 .catch(function() { | |
| 142 assert_unreached('Cache.delete should respect ' + | |
| 143 '"prefixMatch" option.'); | |
| 144 }) | |
| 145 )); | |
| 146 }); | |
| 147 }, 'Cache.delete with CacheQueryOptions.*'); | |
| 148 | |
| 149 prepopulated_cache_test(function(cache) { | |
| 150 return cache.delete('http://example.com/ac', { prefixMatch: true }) | |
| 151 .then(function(result) { | |
| 152 assert_false(result, | |
| 153 'Cache.delete should resolve with "false" if there ' + | |
| 154 'are no matching entries.'); | |
| 155 }); | |
| 156 }, 'Cache.delete with CacheQueryOptions.* that don\'t match'); | |
| 157 | |
| OLD | NEW |