Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/cachestorage/script-tests/cache-delete.js

Issue 1694213002: CacheStorage: Add ignoreSearch option to cache.delete(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary check Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // cache.delete()'s behavior should be the same if ignoreSearch is
101 // not provided or if ignoreSearch is false.
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 it is specified as false)');
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();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698