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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/cachestorage/resources/test-helpers.js

Issue 1485283002: Sync Cache API tests w/ web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 {headers: {'Cookies': 'is-good-enough-for-me'}}), 139 {headers: {'Cookies': 'is-good-enough-for-me'}}),
140 response: new Response('', 140 response: new Response('',
141 {headers: {'Vary': 'Cookies'}}) 141 {headers: {'Vary': 'Cookies'}})
142 }, 142 },
143 143
144 { 144 {
145 name: 'vary_cookie_absent', 145 name: 'vary_cookie_absent',
146 request: new Request('http://example.com/c'), 146 request: new Request('http://example.com/c'),
147 response: new Response('', 147 response: new Response('',
148 {headers: {'Vary': 'Cookies'}}) 148 {headers: {'Vary': 'Cookies'}})
149 },
150
151 {
152 name: 'vary_wildcard',
153 request: new Request('http://example.com/c',
154 {headers: {'Cookies': 'x', 'X-Key': '1'}}),
155 response: new Response('',
156 {headers: {'Vary': '*'}})
157 } 149 }
158 ]; 150 ];
159 151
160 // Run |test_function| with a Cache object and a map of entries. Prior to the 152 // Run |test_function| with a Cache object and a map of entries. Prior to the
161 // call, the Cache is populated by cache entries from |entries|. The latter is 153 // call, the Cache is populated by cache entries from |entries|. The latter is
162 // expected to be an Object mapping arbitrary keys to objects of the form 154 // expected to be an Object mapping arbitrary keys to objects of the form
163 // {request: <Request object>, response: <Response object>}. There's no 155 // {request: <Request object>, response: <Response object>}. There's no
164 // guarantee on the order in which entries will be added to the cache. 156 // guarantee on the order in which entries will be added to the cache.
165 // 157 //
166 // |test_function| should return a Promise that can be used with promise_test. 158 // |test_function| should return a Promise that can be used with promise_test.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 function assert_response_in_array(actual, expected_array, description) { 239 function assert_response_in_array(actual, expected_array, description) {
248 assert_true(expected_array.some(function(element) { 240 assert_true(expected_array.some(function(element) {
249 try { 241 try {
250 assert_response_equals(actual, element); 242 assert_response_equals(actual, element);
251 return true; 243 return true;
252 } catch (e) { 244 } catch (e) {
253 return false; 245 return false;
254 } 246 }
255 }), description); 247 }), description);
256 } 248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698