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/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 var test_url = 'https://example.com/foo'; | 7 var test_url = 'https://example.com/foo'; |
| 8 | 8 |
| 9 // Construct a generic Request object. The URL is |test_url|. All other fields | 9 // Construct a generic Request object. The URL is |test_url|. All other fields |
| 10 // are defaults. | 10 // are defaults. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 | 57 |
| 58 cache_test(function(cache) { | 58 cache_test(function(cache) { |
| 59 return cache.delete(test_url) | 59 return cache.delete(test_url) |
| 60 .then(function(result) { | 60 .then(function(result) { |
| 61 assert_false(result, | 61 assert_false(result, |
| 62 'Cache.delete should resolve with "false" if there ' + | 62 'Cache.delete should resolve with "false" if there ' + |
| 63 'are no matching entries.'); | 63 'are no matching entries.'); |
| 64 }); | 64 }); |
| 65 }, 'Cache.delete with a non-existent entry'); | 65 }, 'Cache.delete with a non-existent entry'); |
| 66 | 66 |
| 67 var cache_entries = { | 67 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 68 a: { | 68 return cache.matchAll(entries.a_with_query.request, |
| 69 request: new Request('http://example.com/abc'), | 69 { ignoreSearch: true }) |
| 70 response: new Response('') | 70 .then(function(result) { |
| 71 assert_response_array_equivalent( | |
| 72 result, | |
| 73 [ | |
| 74 entries.a.response, | |
| 75 entries.a_with_query.response | |
| 76 ]); | |
| 77 return cache.delete(entries.a_with_query.request, | |
| 78 { ignoreSearch: true }); | |
| 79 }) | |
| 80 .then(function(result) { | |
| 81 return cache.matchAll(entries.a_with_query.request, | |
| 82 { ignoreSearch: true }); | |
| 83 }) | |
| 84 .then(function(result) { | |
| 85 assert_response_array_equivalent(result, []); | |
| 86 }); | |
| 71 }, | 87 }, |
| 88 'Cache.delete with ignoreSearch option (request with search parameters)'); | |
| 72 | 89 |
| 73 b: { | 90 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 74 request: new Request('http://example.com/b'), | 91 return cache.matchAll(entries.a_with_query.request, |
| 75 response: new Response('') | 92 { ignoreSearch: true }) |
| 93 .then(function(result) { | |
| 94 assert_response_array_equivalent( | |
| 95 result, | |
| 96 [ | |
| 97 entries.a.response, | |
| 98 entries.a_with_query.response | |
| 99 ]); | |
| 100 // If cache.delete() takes "ignoreSearch: false" explicitly, the | |
| 101 // method has the same behavior when not taking ignoreSearch option. | |
|
jkarlin
2016/02/16 14:54:37
Perhaps:
// cache.delete()'s behavior should be th
zino
2016/02/18 08:12:47
Done.
| |
| 102 return cache.delete(entries.a_with_query.request, | |
| 103 { ignoreSearch: false }); | |
| 104 }) | |
| 105 .then(function(result) { | |
| 106 return cache.matchAll(entries.a_with_query.request, | |
| 107 { ignoreSearch: true }); | |
| 108 }) | |
| 109 .then(function(result) { | |
| 110 assert_response_array_equivalent(result, [ entries.a.response ]); | |
| 111 }); | |
| 76 }, | 112 }, |
| 77 | 113 'Cache.delete with ignoreSearch option (when is specified as false)'); |
|
jkarlin
2016/02/16 14:54:37
s/when is/when it is/
zino
2016/02/18 08:12:47
Done.
| |
| 78 a_with_query: { | |
| 79 request: new Request('http://example.com/abc?q=r'), | |
| 80 response: new Response('') | |
| 81 } | |
| 82 }; | |
| 83 | |
| 84 function prepopulated_cache_test(test_function, description) { | |
| 85 cache_test(function(cache) { | |
| 86 return Promise.all(Object.keys(cache_entries).map(function(k) { | |
| 87 return cache.put(cache_entries[k].request.clone(), | |
| 88 cache_entries[k].response.clone()); | |
| 89 })) | |
| 90 .then(function() { | |
| 91 return test_function(cache); | |
| 92 }); | |
| 93 }, description); | |
| 94 } | |
| 95 | 114 |
| 96 done(); | 115 done(); |
| OLD | NEW |