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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/resources/test-helpers.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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-add.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 (function() { 1 (function() {
2 var next_cache_index = 1; 2 var next_cache_index = 1;
3 3
4 // Returns a promise that resolves to a newly created Cache object. The 4 // Returns a promise that resolves to a newly created Cache object. The
5 // returned Cache will be destroyed when |test| completes. 5 // returned Cache will be destroyed when |test| completes.
6 function create_temporary_cache(test) { 6 function create_temporary_cache(test) {
7 var uniquifier = String(++next_cache_index); 7 var uniquifier = String(++next_cache_index);
8 var cache_name = self.location.pathname + '/' + uniquifier; 8 var cache_name = self.location.pathname + '/' + uniquifier;
9 9
10 test.add_cleanup(function() { 10 test.add_cleanup(function() {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 assert_true(expected_array.some(function(element) { 229 assert_true(expected_array.some(function(element) {
230 try { 230 try {
231 assert_response_equals(actual, element); 231 assert_response_equals(actual, element);
232 return true; 232 return true;
233 } catch (e) { 233 } catch (e) {
234 return false; 234 return false;
235 } 235 }
236 }), description); 236 }), description);
237 } 237 }
238 238
239 // Helper for testing with Request objects. Compares simple
240 // attributes defined on the interfaces, as well as the headers.
241 function assert_request_equals(actual, expected, description) {
242 assert_class_string(actual, "Request", description);
243 ["url"].forEach(function(attribute) {
244 assert_equals(actual[attribute], expected[attribute],
245 description + " Attributes differ: " + attribute + ".");
246 });
247 assert_header_equals(actual.headers, expected.headers, description);
248 }
249
250 // Asserts that two arrays |actual| and |expected| contain the same
251 // set of Requests as determined by assert_request_equals(). The
252 // corresponding elements must occupy corresponding indices in their
253 // respective arrays.
254 function assert_request_array_equals(actual, expected, description) {
255 assert_true(Array.isArray(actual), description);
256 assert_equals(actual.length, expected.length, description);
257 actual.forEach(function(value, index) {
258 assert_request_equals(value, expected[index],
259 description + " : object[" + index + "]");
260 });
261 }
262
239 // Deletes all caches, returning a promise indicating success. 263 // Deletes all caches, returning a promise indicating success.
240 function delete_all_caches() { 264 function delete_all_caches() {
241 return self.caches.keys() 265 return self.caches.keys()
242 .then(function(keys) { 266 .then(function(keys) {
243 return Promise.all(keys.map(self.caches.delete.bind(self.caches))); 267 return Promise.all(keys.map(self.caches.delete.bind(self.caches)));
244 }); 268 });
245 } 269 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-add.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698