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 (function() { | 6 (function() { |
7 var next_index = 1; | 7 var next_index = 1; |
8 | 8 |
9 // Returns a transaction (request, response, and url) for a unique URL. | 9 // Returns a transaction (request, response, and url) for a unique URL. |
10 function create_unique_transaction(test) { | 10 function create_unique_transaction(test) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 .then(function() { | 158 .then(function() { |
159 return self.caches.match(transaction.request, {cacheName: ''}); | 159 return self.caches.match(transaction.request, {cacheName: ''}); |
160 }) | 160 }) |
161 .then(function(response) { | 161 .then(function(response) { |
162 assert_response_equals(response, transaction.response, | 162 assert_response_equals(response, transaction.response, |
163 'The response should be matched.'); | 163 'The response should be matched.'); |
164 return self.caches.delete(''); | 164 return self.caches.delete(''); |
165 }); | 165 }); |
166 }, 'CacheStorageMatch with empty cache name provided'); | 166 }, 'CacheStorageMatch with empty cache name provided'); |
167 | 167 |
| 168 |
| 169 cache_test(function(cache) { |
| 170 var request = new Request('http://example.com/?foo'); |
| 171 var no_query_request = new Request('http://example.com/'); |
| 172 var response = new Response('foo'); |
| 173 return cache.put(request.clone(), response.clone()) |
| 174 .then(function() { |
| 175 return self.caches.match(no_query_request.clone()); |
| 176 }) |
| 177 .then(function(result) { |
| 178 assert_equals( |
| 179 result, undefined, |
| 180 'CacheStorageMatch should resolve as undefined with a ' + |
| 181 'mismatched query.'); |
| 182 return self.caches.match(no_query_request.clone(), |
| 183 {ignoreSearch: true}); |
| 184 }) |
| 185 .then(function(result) { |
| 186 assert_response_equals( |
| 187 result, response, |
| 188 'CacheStorageMatch with ignoreSearch should ignore the ' + |
| 189 'query of the request.'); |
| 190 }); |
| 191 }, 'CacheStorageMatch supports ignoreSearch'); |
| 192 |
| 193 cache_test(function(cache) { |
| 194 var request = new Request('http://example.com/'); |
| 195 var head_request = new Request('http://example.com/', {method: 'HEAD'}); |
| 196 var response = new Response('foo'); |
| 197 return cache.put(request.clone(), response.clone()) |
| 198 .then(function() { |
| 199 return self.caches.match(head_request.clone()); |
| 200 }) |
| 201 .then(function(result) { |
| 202 assert_equals( |
| 203 result, undefined, |
| 204 'CacheStorageMatch should resolve as undefined with a ' + |
| 205 'mismatched method.'); |
| 206 return self.caches.match(head_request.clone(), |
| 207 {ignoreMethod: true}); |
| 208 }) |
| 209 .then(function(result) { |
| 210 assert_response_equals( |
| 211 result, response, |
| 212 'CacheStorageMatch with ignoreMethod should ignore the ' + |
| 213 'method of request.'); |
| 214 }); |
| 215 }, 'Cache.match supports ignoreMethod'); |
| 216 |
| 217 cache_test(function(cache) { |
| 218 var vary_request = new Request('http://example.com/c', |
| 219 {headers: {'Cookies': 'is-for-cookie'}}); |
| 220 var vary_response = new Response('', {headers: {'Vary': 'Cookies'}}); |
| 221 var mismatched_vary_request = new Request('http://example.com/c'); |
| 222 |
| 223 return cache.put(vary_request.clone(), vary_response.clone()) |
| 224 .then(function() { |
| 225 return self.caches.match(mismatched_vary_request.clone()); |
| 226 }) |
| 227 .then(function(result) { |
| 228 assert_equals( |
| 229 result, undefined, |
| 230 'CacheStorageMatch should resolve as undefined with a ' + |
| 231 ' mismatched vary.'); |
| 232 return self.caches.match(mismatched_vary_request.clone(), |
| 233 {ignoreVary: true}); |
| 234 }) |
| 235 .then(function(result) { |
| 236 assert_response_equals( |
| 237 result, vary_response, |
| 238 'CacheStorageMatch with ignoreVary should ignore the ' + |
| 239 'vary of request.'); |
| 240 }); |
| 241 }, 'CacheStorageMatch supports ignoreVary'); |
| 242 |
168 done(); | 243 done(); |
OLD | NEW |