| OLD | NEW |
| 1 if (self.importScripts) { | 1 if (self.importScripts) { |
| 2 importScripts('/resources/testharness.js'); | 2 importScripts('/resources/testharness.js'); |
| 3 importScripts('/resources/testharness-helpers.js'); | 3 importScripts('/resources/testharness-helpers.js'); |
| 4 importScripts('../resources/test-helpers.js'); | 4 importScripts('../resources/test-helpers.js'); |
| 5 } | 5 } |
| 6 | 6 |
| 7 prepopulated_cache_test(simple_entries, function(cache, entries) { | 7 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 8 return cache.match('not-present-in-the-cache') | 8 return cache.match('not-present-in-the-cache') |
| 9 .then(function(result) { | 9 .then(function(result) { |
| 10 assert_equals(result, undefined, | 10 assert_equals(result, undefined, |
| 11 'Cache.match failures should resolve with undefined.'); | 11 'Cache.match failures should resolve with undefined.'); |
| 12 }); | 12 }); |
| 13 }, 'Cache.match with no matching entries'); | 13 }, 'Cache.match with no matching entries'); |
| 14 | 14 |
| 15 prepopulated_cache_test(simple_entries, function(cache, entries) { | 15 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 16 return cache.match(entries.a.request.url) | 16 return cache.match(entries.a.request.url) |
| 17 .then(function(result) { | 17 .then(function(result) { |
| 18 assert_response_equals(result, entries.a.response, | 18 assert_response_equals(result, entries.a.response, |
| 19 'Cache.match should match by URL.'); | 19 'Cache.match should match by URL.'); |
| 20 }); | 20 }); |
| 21 }, 'Cache.match with URL'); | 21 }, 'Cache.match with URL'); |
| 22 | 22 |
| 23 prepopulated_cache_test(simple_entries, function(cache, entries) { | 23 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 24 return cache.match(entries.a.request) | 24 return cache.match(entries.a.request) |
| 25 .then(function(result) { | 25 .then(function(result) { |
| 26 assert_response_equals(result, entries.a.response, | 26 assert_response_equals(result, entries.a.response, |
| 27 'Cache.match should match by Request.'); | 27 'Cache.match should match by Request.'); |
| 28 }); | 28 }); |
| 29 }, 'Cache.match with Request'); | 29 }, 'Cache.match with Request'); |
| 30 | 30 |
| 31 prepopulated_cache_test(simple_entries, function(cache, entries) { | 31 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 32 return cache.match(new Request(entries.a.request.url)) | 32 return cache.match(new Request(entries.a.request.url)) |
| 33 .then(function(result) { | 33 .then(function(result) { |
| 34 assert_response_equals(result, entries.a.response, | 34 assert_response_equals(result, entries.a.response, |
| 35 'Cache.match should match by Request.'); | 35 'Cache.match should match by Request.'); |
| 36 }); | 36 }); |
| 37 }, 'Cache.match with new Request'); | 37 }, 'Cache.match with new Request'); |
| 38 | 38 |
| 39 prepopulated_cache_test(simple_entries, function(cache, entries) { | 39 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 40 return cache.match(entries.a.request, | 40 return cache.match(entries.a.request, |
| 41 {ignoreSearch: true}) | 41 {ignoreSearch: true}) |
| 42 .then(function(result) { | 42 .then(function(result) { |
| 43 assert_response_in_array( | 43 assert_response_in_array( |
| 44 result, | 44 result, |
| 45 [ | 45 [ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 'Cache.match with ignoreSearch should ignore the ' + | 66 'Cache.match with ignoreSearch should ignore the ' + |
| 67 'search parameters of request.'); | 67 'search parameters of request.'); |
| 68 }); | 68 }); |
| 69 }, | 69 }, |
| 70 'Cache.match with ignoreSearch option (request with search parameter)'); | 70 'Cache.match with ignoreSearch option (request with search parameter)'); |
| 71 | 71 |
| 72 prepopulated_cache_test(simple_entries, function(cache, entries) { | 72 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 73 return cache.match(entries.cat.request.url + '#mouse') | 73 return cache.match(entries.cat.request.url + '#mouse') |
| 74 .then(function(result) { | 74 .then(function(result) { |
| 75 assert_response_equals(result, entries.cat.response, | 75 assert_response_equals(result, entries.cat.response, |
| 76 'Cache.match should ignore URL fragment.'); | 76 'Cache.match should ignore URL fragment.'); |
| 77 }); | 77 }); |
| 78 }, 'Cache.match with URL containing fragment'); | 78 }, 'Cache.match with URL containing fragment'); |
| 79 | 79 |
| 80 prepopulated_cache_test(simple_entries, function(cache, entries) { | 80 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 81 return cache.match('http') | 81 return cache.match('http') |
| 82 .then(function(result) { | 82 .then(function(result) { |
| 83 assert_equals( | 83 assert_equals( |
| 84 result, undefined, | 84 result, undefined, |
| 85 'Cache.match should treat query as a URL and not ' + | 85 'Cache.match should treat query as a URL and not ' + |
| 86 'just a string fragment.'); | 86 'just a string fragment.'); |
| 87 }); | 87 }); |
| 88 }, 'Cache.match with string fragment "http" as query'); | 88 }, 'Cache.match with string fragment "http" as query'); |
| 89 | 89 |
| 90 prepopulated_cache_test(simple_entries, function(cache, entries) { | 90 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 91 return cache.match(entries.secret_cat.request.url) | 91 return cache.match(entries.secret_cat.request.url) |
| 92 .then(function(result) { | 92 .then(function(result) { |
| 93 assert_response_equals( | 93 assert_response_equals( |
| 94 result, entries.secret_cat.response, | 94 result, entries.secret_cat.response, |
| 95 'Cache.match should not ignore embedded credentials'); | 95 'Cache.match should not ignore embedded credentials'); |
| 96 }); | 96 }); |
| 97 }, 'Cache.match with URL containing credentials'); | 97 }, 'Cache.match with URL containing credentials'); |
| 98 | 98 |
| 99 prepopulated_cache_test(vary_entries, function(cache, entries) { | 99 prepopulated_cache_test(vary_entries, function(cache, entries) { |
| 100 return cache.match('http://example.com/c') | 100 return cache.match('http://example.com/c') |
| 101 .then(function(result) { | 101 .then(function(result) { |
| 102 assert_response_in_array( | 102 assert_response_in_array( |
| 103 result, | 103 result, |
| 104 [ | 104 [ |
| 105 entries.vary_wildcard.response, | |
| 106 entries.vary_cookie_absent.response | 105 entries.vary_cookie_absent.response |
| 107 ], | 106 ], |
| 108 'Cache.match should honor "Vary" header.'); | 107 'Cache.match should honor "Vary" header.'); |
| 109 }); | 108 }); |
| 110 }, 'Cache.match with responses containing "Vary" header'); | 109 }, 'Cache.match with responses containing "Vary" header'); |
| 111 | 110 |
| 112 cache_test(function(cache) { | 111 cache_test(function(cache) { |
| 113 var request = new Request('http://example.com'); | 112 var request = new Request('http://example.com'); |
| 114 var response; | 113 var response; |
| 115 var request_url = new URL('../resources/simple.txt', location.href).href; | 114 var request_url = new URL('../resources/simple.txt', location.href).href; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 'valid body each time it is called.'); | 167 'valid body each time it is called.'); |
| 169 }); | 168 }); |
| 170 }, 'Cache.match invoked multiple times for the same Request/Response'); | 169 }, 'Cache.match invoked multiple times for the same Request/Response'); |
| 171 | 170 |
| 172 prepopulated_cache_test(simple_entries, function(cache, entries) { | 171 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 173 var request = new Request(entries.a.request.clone(), {method: 'POST'}); | 172 var request = new Request(entries.a.request.clone(), {method: 'POST'}); |
| 174 return cache.match(request) | 173 return cache.match(request) |
| 175 .then(function(result) { | 174 .then(function(result) { |
| 176 assert_equals(result, undefined, | 175 assert_equals(result, undefined, |
| 177 'Cache.match should not find a match'); | 176 'Cache.match should not find a match'); |
| 178 }); | 177 }); |
| 179 }, 'Cache.match with POST Request'); | 178 }, 'Cache.match with POST Request'); |
| 180 | 179 |
| 181 prepopulated_cache_test(simple_entries, function(cache, entries) { | 180 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 182 var response = entries.non_2xx_response.response; | 181 var response = entries.non_2xx_response.response; |
| 183 return cache.match(entries.non_2xx_response.request.url) | 182 return cache.match(entries.non_2xx_response.request.url) |
| 184 .then(function(result) { | 183 .then(function(result) { |
| 185 assert_response_equals( | 184 assert_response_equals( |
| 186 result, entries.non_2xx_response.response, | 185 result, entries.non_2xx_response.response, |
| 187 'Cache.match should return a Response object that has the ' + | 186 'Cache.match should return a Response object that has the ' + |
| 188 'same properties as a stored non-2xx response.'); | 187 'same properties as a stored non-2xx response.'); |
| 189 }); | 188 }); |
| 190 }, 'Cache.match with a non-2xx Response'); | 189 }, 'Cache.match with a non-2xx Response'); |
| 191 | 190 |
| 192 prepopulated_cache_test(simple_entries, function(cache, entries) { | 191 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 193 var response = entries.error_response.response; | 192 var response = entries.error_response.response; |
| 194 return cache.match(entries.error_response.request.url) | 193 return cache.match(entries.error_response.request.url) |
| 195 .then(function(result) { | 194 .then(function(result) { |
| 196 assert_response_equals( | 195 assert_response_equals( |
| 197 result, entries.error_response.response, | 196 result, entries.error_response.response, |
| 198 'Cache.match should return a Response object that has the ' + | 197 'Cache.match should return a Response object that has the ' + |
| 199 'same properties as a stored network error response.'); | 198 'same properties as a stored network error response.'); |
| 200 }); | 199 }); |
| 201 }, 'Cache.match with a network error Response'); | 200 }, 'Cache.match with a network error Response'); |
| 202 | 201 |
| 203 done(); | 202 done(); |
| OLD | NEW |