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 prepopulated_cache_test(simple_entries, function(cache, entries) { | 6 prepopulated_cache_test(simple_entries, function(cache, entries) { |
7 return cache.match('not-present-in-the-cache') | 7 return cache.match('not-present-in-the-cache') |
8 .then(function(result) { | 8 .then(function(result) { |
9 assert_equals(result, undefined, | 9 assert_equals(result, undefined, |
10 'Cache.match failures should resolve with undefined.'); | 10 'Cache.match failures should resolve with undefined.'); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 [ | 86 [ |
87 entries.a.response, | 87 entries.a.response, |
88 entries.a_with_query.response | 88 entries.a_with_query.response |
89 ], | 89 ], |
90 'Cache.match with ignoreSearch should ignore the ' + | 90 'Cache.match with ignoreSearch should ignore the ' + |
91 'search parameters of request.'); | 91 'search parameters of request.'); |
92 }); | 92 }); |
93 }, | 93 }, |
94 'Cache.match with ignoreSearch option (request with search parameter)'); | 94 'Cache.match with ignoreSearch option (request with search parameter)'); |
95 | 95 |
| 96 cache_test(function(cache) { |
| 97 var request = new Request('http://example.com/'); |
| 98 var head_request = new Request('http://example.com/', {method: 'HEAD'}); |
| 99 var response = new Response('foo'); |
| 100 return cache.put(request.clone(), response.clone()) |
| 101 .then(function() { |
| 102 return cache.match(head_request.clone()); |
| 103 }) |
| 104 .then(function(result) { |
| 105 assert_equals( |
| 106 result, undefined, |
| 107 'Cache.match should resolve as undefined with a ' + |
| 108 'mismatched method.'); |
| 109 return cache.match(head_request.clone(), |
| 110 {ignoreMethod: true}); |
| 111 }) |
| 112 .then(function(result) { |
| 113 assert_response_equals( |
| 114 result, response, |
| 115 'Cache.match with ignoreMethod should ignore the ' + |
| 116 'method of request.'); |
| 117 }); |
| 118 }, 'Cache.match supports ignoreMethod'); |
| 119 |
| 120 cache_test(function(cache) { |
| 121 var vary_request = new Request('http://example.com/c', |
| 122 {headers: {'Cookies': 'is-for-cookie'}}); |
| 123 var vary_response = new Response('', {headers: {'Vary': 'Cookies'}}); |
| 124 var mismatched_vary_request = new Request('http://example.com/c'); |
| 125 |
| 126 return cache.put(vary_request.clone(), vary_response.clone()) |
| 127 .then(function() { |
| 128 return cache.match(mismatched_vary_request.clone()); |
| 129 }) |
| 130 .then(function(result) { |
| 131 assert_equals( |
| 132 result, undefined, |
| 133 'Cache.match should resolve as undefined with a ' + |
| 134 'mismatched vary.'); |
| 135 return cache.match(mismatched_vary_request.clone(), |
| 136 {ignoreVary: true}); |
| 137 }) |
| 138 .then(function(result) { |
| 139 assert_response_equals( |
| 140 result, vary_response, |
| 141 'Cache.match with ignoreVary should ignore the ' + |
| 142 'vary of request.'); |
| 143 }); |
| 144 }, 'Cache.match supports ignoreVary'); |
| 145 |
96 prepopulated_cache_test(simple_entries, function(cache, entries) { | 146 prepopulated_cache_test(simple_entries, function(cache, entries) { |
97 return cache.match(entries.cat.request.url + '#mouse') | 147 return cache.match(entries.cat.request.url + '#mouse') |
98 .then(function(result) { | 148 .then(function(result) { |
99 assert_response_equals(result, entries.cat.response, | 149 assert_response_equals(result, entries.cat.response, |
100 'Cache.match should ignore URL fragment.'); | 150 'Cache.match should ignore URL fragment.'); |
101 }); | 151 }); |
102 }, 'Cache.match with URL containing fragment'); | 152 }, 'Cache.match with URL containing fragment'); |
103 | 153 |
104 prepopulated_cache_test(simple_entries, function(cache, entries) { | 154 prepopulated_cache_test(simple_entries, function(cache, entries) { |
105 return cache.match('http') | 155 return cache.match('http') |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 return cache.match(entries.error_response.request.url) | 288 return cache.match(entries.error_response.request.url) |
239 .then(function(result) { | 289 .then(function(result) { |
240 assert_response_equals( | 290 assert_response_equals( |
241 result, entries.error_response.response, | 291 result, entries.error_response.response, |
242 'Cache.match should return a Response object that has the ' + | 292 'Cache.match should return a Response object that has the ' + |
243 'same properties as a stored network error response.'); | 293 'same properties as a stored network error response.'); |
244 }); | 294 }); |
245 }, 'Cache.match with a network error Response'); | 295 }, 'Cache.match with a network error Response'); |
246 | 296 |
247 done(); | 297 done(); |
OLD | NEW |