OLD | NEW |
1 importScripts('worker-testharness.js'); | 1 importScripts('worker-testharness.js'); |
2 importScripts('/resources/testharness-helpers.js'); | 2 importScripts('/resources/testharness-helpers.js'); |
3 | 3 |
4 var test_url = 'https://example.com/foo'; | 4 var test_url = 'https://example.com/foo'; |
5 | 5 |
6 // Construct a generic Request object. The URL is |test_url|. All other fields | 6 // Construct a generic Request object. The URL is |test_url|. All other fields |
7 // are defaults. | 7 // are defaults. |
8 function new_test_request() { | 8 function new_test_request() { |
9 return new Request(test_url); | 9 return new Request(test_url); |
10 } | 10 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 }); | 153 }); |
154 }, 'Cache.put called twice with same Request and different Responses'); | 154 }, 'Cache.put called twice with same Request and different Responses'); |
155 | 155 |
156 cache_test(function(cache) { | 156 cache_test(function(cache) { |
157 return assert_promise_rejects( | 157 return assert_promise_rejects( |
158 cache.put('http://example.com/foo', new_test_response()), | 158 cache.put('http://example.com/foo', new_test_response()), |
159 new TypeError(), | 159 new TypeError(), |
160 'Cache.put should only accept a Request object as the request.'); | 160 'Cache.put should only accept a Request object as the request.'); |
161 }, 'Cache.put with an invalid request'); | 161 }, 'Cache.put with an invalid request'); |
162 | 162 |
163 // TODO: This test currently causes a renderer crash. Enable test again once the | 163 cache_test(function(cache) { |
164 // crash is resolved. http://crbug.com/426153 | 164 return assert_promise_rejects( |
165 if (false) { | 165 cache.put(new_test_request(), 'Hello world!'), |
166 cache_test(function(cache) { | 166 new TypeError(), |
167 return assert_promise_rejects( | 167 'Cache.put should only accept a Response object as the response.'); |
168 cache.put(new_test_request(), 'Hello world!'), | 168 }, 'Cache.put with an invalid response'); |
169 new TypeError(), | |
170 'Cache.put should only accept a Response object as the response.'); | |
171 }, 'Cache.put with an invalid response'); | |
172 } | |
173 | 169 |
174 cache_test(function(cache) { | 170 cache_test(function(cache) { |
175 return assert_promise_rejects( | 171 return assert_promise_rejects( |
176 cache.put(new Request('file:///etc/passwd'), new_test_response()), | 172 cache.put(new Request('file:///etc/passwd'), new_test_response()), |
177 new TypeError(), | 173 new TypeError(), |
178 'Cache.put should reject non-HTTP/HTTPS requests with a TypeError.'); | 174 'Cache.put should reject non-HTTP/HTTPS requests with a TypeError.'); |
179 }, 'Cache.put with a non-HTTP/HTTPS request'); | 175 }, 'Cache.put with a non-HTTP/HTTPS request'); |
180 | 176 |
181 cache_test(function(cache) { | 177 cache_test(function(cache) { |
182 var response = new_test_response(); | 178 var response = new_test_response(); |
(...skipping 17 matching lines...) Expand all Loading... |
200 }, 'Cache.put with a non-GET request'); | 196 }, 'Cache.put with a non-GET request'); |
201 | 197 |
202 cache_test(function(cache) { | 198 cache_test(function(cache) { |
203 var request = new Request('http://example.com/foo', {method: 'HEAD'}); | 199 var request = new Request('http://example.com/foo', {method: 'HEAD'}); |
204 return assert_promise_rejects( | 200 return assert_promise_rejects( |
205 cache.put(request, new_test_response()), | 201 cache.put(request, new_test_response()), |
206 new TypeError(), | 202 new TypeError(), |
207 'Cache.put should throw a TypeError for non-GET requests.'); | 203 'Cache.put should throw a TypeError for non-GET requests.'); |
208 }, 'Cache.put with a non-GET request'); | 204 }, 'Cache.put with a non-GET request'); |
209 | 205 |
210 // TODO: This test currently causes a renderer crash. Enable test again once the | 206 cache_test(function(cache) { |
211 // crash is resolved. http://crbug.com/426153 | 207 return assert_promise_rejects( |
212 if (false) { | 208 cache.put(new_test_request(), null), |
213 cache_test(function(cache) { | 209 new TypeError(), |
214 return assert_promise_rejects( | 210 'Cache.put should throw a TypeError for an empty response.'); |
215 cache.put(new_test_request(), null), | 211 }, 'Cache.put with an empty response'); |
216 new TypeError(), | |
217 'Cache.put should throw a TypeError for an empty response.'); | |
218 }, 'Cache.put with an empty response'); | |
219 } | |
OLD | NEW |