| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 var request = new_test_request(); | 95 var request = new_test_request(); |
| 96 var response = new Response('', { | 96 var response = new Response('', { |
| 97 status: 200, | 97 status: 200, |
| 98 headers: [['Content-Type', 'text/plain']] | 98 headers: [['Content-Type', 'text/plain']] |
| 99 }); | 99 }); |
| 100 return cache.put(request, response) | 100 return cache.put(request, response) |
| 101 .then(function() { | 101 .then(function() { |
| 102 return cache.match(test_url); | 102 return cache.match(test_url); |
| 103 }) | 103 }) |
| 104 .then(function(result) { | 104 .then(function(result) { |
| 105 assert_object_equals(result, response, | 105 assert_equals(result.status, 200, 'Cache.put should store status.'); |
| 106 'Cache.put should update the cache with ' + | 106 assert_equals(result.headers.get('Content-Type'), 'text/plain', |
| 107 'new request and response.'); | 107 'Cache.put should store headers.'); |
| 108 return result.text(); | 108 return result.text(); |
| 109 }) | 109 }) |
| 110 .then(function(body) { | 110 .then(function(body) { |
| 111 assert_equals(body, '', | 111 assert_equals(body, '', |
| 112 'Cache.put should store response body.'); | 112 'Cache.put should store response body.'); |
| 113 }); | 113 }); |
| 114 }, 'Cache.put with an empty response body'); | 114 }, 'Cache.put with an empty response body'); |
| 115 | 115 |
| 116 cache_test(function(cache) { | 116 cache_test(function(cache) { |
| 117 var test_url = new URL('fetch-status.php?status=500', location.href).href; | 117 var test_url = new URL('fetch-status.php?status=500', location.href).href; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 new TypeError(), | 202 new TypeError(), |
| 203 'Cache.put should throw a TypeError for non-GET requests.'); | 203 'Cache.put should throw a TypeError for non-GET requests.'); |
| 204 }, 'Cache.put with a non-GET request'); | 204 }, 'Cache.put with a non-GET request'); |
| 205 | 205 |
| 206 cache_test(function(cache) { | 206 cache_test(function(cache) { |
| 207 return assert_promise_rejects( | 207 return assert_promise_rejects( |
| 208 cache.put(new_test_request(), null), | 208 cache.put(new_test_request(), null), |
| 209 new TypeError(), | 209 new TypeError(), |
| 210 'Cache.put should throw a TypeError for an empty response.'); | 210 'Cache.put should throw a TypeError for an empty response.'); |
| 211 }, 'Cache.put with an empty response'); | 211 }, 'Cache.put with an empty response'); |
| OLD | NEW |