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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-storage-match.js

Issue 2790143003: Cache Storage API tests: Fix WPT test bugs, remove redundant local copies (Closed)
Patch Set: Created 3 years, 8 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/test-helpers.js'); 3 importScripts('../resources/test-helpers.js');
4 } 4 }
5 5
6 (function() { 6 (function() {
7 var next_index = 1; 7 var next_index = 1;
8 8
9 // Returns a transaction (request, response, and url) for a unique URL. 9 // Returns a transaction (request, response, and url) for a unique URL.
10 function create_unique_transaction(test) { 10 function create_unique_transaction(test) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 assert_equals(response, undefined, 126 assert_equals(response, undefined,
127 'The match with bad cache name should resolve to ' + 127 'The match with bad cache name should resolve to ' +
128 'undefined.'); 128 'undefined.');
129 return self.caches.has('foo'); 129 return self.caches.has('foo');
130 }) 130 })
131 .then(function(has_foo) { 131 .then(function(has_foo) {
132 assert_false(has_foo, "The cache should still not exist."); 132 assert_false(has_foo, "The cache should still not exist.");
133 }); 133 });
134 }, 'CacheStorageMatch with no caches available but name provided'); 134 }, 'CacheStorageMatch with no caches available but name provided');
135 135
136 cache_test(function(cache) {
137 var transaction = create_unique_transaction();
138
139 return self.caches.delete('')
140 .then(function() {
141 return self.caches.has('');
142 })
143 .then(function(has_cache) {
144 assert_false(has_cache, "The cache should not exist.");
145 return cache.put(transaction.request, transaction.response.clone());
146 })
147 .then(function() {
148 return self.caches.match(transaction.request, {cacheName: ''});
149 })
150 .then(function(response) {
151 assert_equals(response, undefined,
152 'The response should not be found.');
153 return self.caches.open('');
154 })
155 .then(function(cache) {
156 return cache.put(transaction.request, transaction.response);
157 })
158 .then(function() {
159 return self.caches.match(transaction.request, {cacheName: ''});
160 })
161 .then(function(response) {
162 assert_response_equals(response, transaction.response,
163 'The response should be matched.');
164 return self.caches.delete('');
165 });
166 }, 'CacheStorageMatch with empty cache name provided');
167
168 cache_test(function(cache) {
169 var request = new Request('http://example.com/?foo');
170 var no_query_request = new Request('http://example.com/');
171 var response = new Response('foo');
172 return cache.put(request.clone(), response.clone())
173 .then(function() {
174 return self.caches.match(no_query_request.clone());
175 })
176 .then(function(result) {
177 assert_equals(
178 result, undefined,
179 'CacheStorageMatch should resolve as undefined with a ' +
180 'mismatched query.');
181 return self.caches.match(no_query_request.clone(),
182 {ignoreSearch: true});
183 })
184 .then(function(result) {
185 assert_response_equals(
186 result, response,
187 'CacheStorageMatch with ignoreSearch should ignore the ' +
188 'query of the request.');
189 });
190 }, 'CacheStorageMatch supports ignoreSearch');
191
192 cache_test(function(cache) {
193 var request = new Request('http://example.com/');
194 var head_request = new Request('http://example.com/', {method: 'HEAD'});
195 var response = new Response('foo');
196 return cache.put(request.clone(), response.clone())
197 .then(function() {
198 return self.caches.match(head_request.clone());
199 })
200 .then(function(result) {
201 assert_equals(
202 result, undefined,
203 'CacheStorageMatch should resolve as undefined with a ' +
204 'mismatched method.');
205 return self.caches.match(head_request.clone(),
206 {ignoreMethod: true});
207 })
208 .then(function(result) {
209 assert_response_equals(
210 result, response,
211 'CacheStorageMatch with ignoreMethod should ignore the ' +
212 'method of request.');
213 });
214 }, 'Cache.match supports ignoreMethod');
215
216 cache_test(function(cache) {
217 var vary_request = new Request('http://example.com/c',
218 {headers: {'Cookies': 'is-for-cookie'}});
219 var vary_response = new Response('', {headers: {'Vary': 'Cookies'}});
220 var mismatched_vary_request = new Request('http://example.com/c');
221
222 return cache.put(vary_request.clone(), vary_response.clone())
223 .then(function() {
224 return self.caches.match(mismatched_vary_request.clone());
225 })
226 .then(function(result) {
227 assert_equals(
228 result, undefined,
229 'CacheStorageMatch should resolve as undefined with a ' +
230 ' mismatched vary.');
231 return self.caches.match(mismatched_vary_request.clone(),
232 {ignoreVary: true});
233 })
234 .then(function(result) {
235 assert_response_equals(
236 result, vary_response,
237 'CacheStorageMatch with ignoreVary should ignore the ' +
238 'vary of request.');
239 });
240 }, 'CacheStorageMatch supports ignoreVary');
241
136 done(); 242 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698