Chromium Code Reviews| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 return cache.match(test_url); | 147 return cache.match(test_url); |
| 148 }) | 148 }) |
| 149 .then(function(result) { | 149 .then(function(result) { |
| 150 assert_object_equals(result, alternate_response, | 150 assert_object_equals(result, alternate_response, |
| 151 'Cache.put should replace existing ' + | 151 'Cache.put should replace existing ' + |
| 152 'response with new response.'); | 152 'response with new response.'); |
| 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 var url = 'http://example.com/foo'; |
| 158 cache.put('http://example.com/foo', new_test_response()), | 158 return cache.put(url, new_test_response('some body')) |
| 159 new TypeError(), | 159 .then(function() { return cache.match(url); }) |
| 160 'Cache.put should only accept a Request object as the request.'); | 160 .then(function(response) { return response.text(); }) |
| 161 }, 'Cache.put with an invalid request'); | 161 .then(function(body) { |
| 162 assert_equals(body, 'some body', | |
| 163 'Cache.put should accept a string as request'); | |
|
asanka
2014/10/24 04:59:07
Minor nit: I've been including the ending period i
| |
| 164 }); | |
| 165 }, 'Cache.put with an string request'); | |
| 162 | 166 |
| 163 cache_test(function(cache) { | 167 cache_test(function(cache) { |
| 164 return assert_promise_rejects( | 168 return assert_promise_rejects( |
| 165 cache.put(new_test_request(), 'Hello world!'), | 169 cache.put(new_test_request(), 'Hello world!'), |
| 166 new TypeError(), | 170 new TypeError(), |
| 167 'Cache.put should only accept a Response object as the response.'); | 171 'Cache.put should only accept a Response object as the response.'); |
| 168 }, 'Cache.put with an invalid response'); | 172 }, 'Cache.put with an invalid response'); |
| 169 | 173 |
| 170 cache_test(function(cache) { | 174 cache_test(function(cache) { |
| 171 return assert_promise_rejects( | 175 return assert_promise_rejects( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 202 new TypeError(), | 206 new TypeError(), |
| 203 'Cache.put should throw a TypeError for non-GET requests.'); | 207 'Cache.put should throw a TypeError for non-GET requests.'); |
| 204 }, 'Cache.put with a non-GET request'); | 208 }, 'Cache.put with a non-GET request'); |
| 205 | 209 |
| 206 cache_test(function(cache) { | 210 cache_test(function(cache) { |
| 207 return assert_promise_rejects( | 211 return assert_promise_rejects( |
| 208 cache.put(new_test_request(), null), | 212 cache.put(new_test_request(), null), |
| 209 new TypeError(), | 213 new TypeError(), |
| 210 'Cache.put should throw a TypeError for an empty response.'); | 214 'Cache.put should throw a TypeError for an empty response.'); |
| 211 }, 'Cache.put with an empty response'); | 215 }, 'Cache.put with an empty response'); |
| OLD | NEW |