| OLD | NEW |
| 1 if (self.importScripts) { | 1 if (self.importScripts) { |
| 2 importScripts('/resources/testharness.js'); | 2 importScripts('/resources/testharness.js'); |
| 3 importScripts('../resources/test-helpers.js'); | 3 importScripts('../resources/test-helpers.js'); |
| 4 } | 4 } |
| 5 | 5 |
| 6 var test_url = 'https://example.com/foo'; | 6 var test_url = 'https://example.com/foo'; |
| 7 var test_body = 'Hello world!'; | 7 var test_body = 'Hello world!'; |
| 8 | 8 |
| 9 cache_test(function(cache) { | 9 cache_test(function(cache) { |
| 10 var request = new Request(test_url); | 10 var request = new Request(test_url); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 'Cache.put should update the cache with ' + | 121 'Cache.put should update the cache with ' + |
| 122 'new request and response.'); | 122 'new request and response.'); |
| 123 return result.text(); | 123 return result.text(); |
| 124 }) | 124 }) |
| 125 .then(function(body) { | 125 .then(function(body) { |
| 126 assert_equals(body, '', | 126 assert_equals(body, '', |
| 127 'Cache.put should store response body.'); | 127 'Cache.put should store response body.'); |
| 128 }); | 128 }); |
| 129 }, 'Cache.put with HTTP 500 response'); | 129 }, 'Cache.put with HTTP 500 response'); |
| 130 | 130 |
| 131 cache_test(function(cache, test) { |
| 132 var test_url = new URL('../resources/fetch-status.php?status=206', location.
href).href; |
| 133 var request = new Request(test_url); |
| 134 var response; |
| 135 return fetch(test_url) |
| 136 .then(function(fetch_result) { |
| 137 assert_equals(fetch_result.status, 206, |
| 138 'Test framework error: The status code should be 206.'); |
| 139 response = fetch_result.clone(); |
| 140 return promise_rejects(test, new TypeError, cache.put(request, fetch_r
esult)); |
| 141 }); |
| 142 }, 'Cache.put with HTTP 206 response'); |
| 143 |
| 131 cache_test(function(cache) { | 144 cache_test(function(cache) { |
| 132 var alternate_response_body = 'New body'; | 145 var alternate_response_body = 'New body'; |
| 133 var alternate_response = new Response(alternate_response_body, | 146 var alternate_response = new Response(alternate_response_body, |
| 134 { statusText: 'New status' }); | 147 { statusText: 'New status' }); |
| 135 return cache.put(new Request(test_url), | 148 return cache.put(new Request(test_url), |
| 136 new Response('Old body', { statusText: 'Old status' })) | 149 new Response('Old body', { statusText: 'Old status' })) |
| 137 .then(function() { | 150 .then(function() { |
| 138 return cache.put(new Request(test_url), alternate_response.clone()); | 151 return cache.put(new Request(test_url), alternate_response.clone()); |
| 139 }) | 152 }) |
| 140 .then(function() { | 153 .then(function() { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 test, | 297 test, |
| 285 new TypeError(), | 298 new TypeError(), |
| 286 cache.put(new Request(test_url), | 299 cache.put(new Request(test_url), |
| 287 new Response(test_body, | 300 new Response(test_body, |
| 288 { headers: { VARY: 'Accept-Language,*' }})), | 301 { headers: { VARY: 'Accept-Language,*' }})), |
| 289 'Cache.put should reject Responses with an embedded VARY:* with a ' + | 302 'Cache.put should reject Responses with an embedded VARY:* with a ' + |
| 290 'TypeError.'); | 303 'TypeError.'); |
| 291 }, 'Cache.put with an embedded VARY:* Response'); | 304 }, 'Cache.put with an embedded VARY:* Response'); |
| 292 | 305 |
| 293 done(); | 306 done(); |
| OLD | NEW |