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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/resources/test-helpers.js

Issue 2547023002: Import wpt@3c8896ae408c8fd594979da7c99970029e7856a7 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 4 years 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 (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 14 matching lines...) Expand all
25 // promise_test(). As such, it is expected to behave in a manner identical (with 25 // promise_test(). As such, it is expected to behave in a manner identical (with
26 // the exception of the argument) to a function passed into promise_test(). 26 // the exception of the argument) to a function passed into promise_test().
27 // 27 //
28 // E.g.: 28 // E.g.:
29 // cache_test(function(cache) { 29 // cache_test(function(cache) {
30 // // Do something with |cache|, which is a Cache object. 30 // // Do something with |cache|, which is a Cache object.
31 // }, "Some Cache test"); 31 // }, "Some Cache test");
32 function cache_test(test_function, description) { 32 function cache_test(test_function, description) {
33 promise_test(function(test) { 33 promise_test(function(test) {
34 return create_temporary_cache(test) 34 return create_temporary_cache(test)
35 .then(test_function); 35 .then(function(cache) { return test_function(cache, test); });
36 }, description); 36 }, description);
37 } 37 }
38 38
39 // A set of Request/Response pairs to be used with prepopulated_cache_test(). 39 // A set of Request/Response pairs to be used with prepopulated_cache_test().
40 var simple_entries = [ 40 var simple_entries = [
41 { 41 {
42 name: 'a', 42 name: 'a',
43 request: new Request('http://example.com/a'), 43 request: new Request('http://example.com/a'),
44 response: new Response('') 44 response: new Response('')
45 }, 45 },
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 function assert_response_in_array(actual, expected_array, description) { 228 function assert_response_in_array(actual, expected_array, description) {
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
239 // Deletes all caches, returning a promise indicating success.
240 function delete_all_caches() {
241 return self.caches.keys()
242 .then(function(keys) {
243 return Promise.all(keys.map(self.caches.delete.bind(self.caches)));
244 });
245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698