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 | 7 |
8 // Construct a generic Request object. The URL is |test_url|. All other fields | 8 // Construct a generic Request object. The URL is |test_url|. All other fields |
9 // are defaults. | 9 // are defaults. |
10 function new_test_request() { | 10 function new_test_request() { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 cache_test(function(cache) { | 58 cache_test(function(cache) { |
59 var request = new Request(test_url); | 59 var request = new Request(test_url); |
60 var response = new_test_response(); | 60 var response = new_test_response(); |
61 return cache.put(request, response) | 61 return cache.put(request, response) |
62 .then(function() { | 62 .then(function() { |
63 return cache.delete(new Request(test_url, {method: 'HEAD'})); | 63 return cache.delete(new Request(test_url, {method: 'HEAD'})); |
64 }) | 64 }) |
65 .then(function(result) { | 65 .then(function(result) { |
66 assert_false(result, | 66 assert_false(result, |
67 'Cache.delete should not match a non-GET request ' + | 67 'Cache.delete should not match a non-GET request ' + |
68 'unless ignoreMethod option is set.'); | 68 'unless ignoreMethod option is set.'); |
69 return cache.match(test_url); | 69 return cache.match(test_url); |
70 }) | 70 }) |
71 .then(function(result) { | 71 .then(function(result) { |
72 assert_response_equals(result, response, | 72 assert_response_equals(result, response, |
73 'Cache.delete should leave non-matching response in the cache.'); | 73 'Cache.delete should leave non-matching response in the cache.'); |
| 74 return cache.delete(new Request(test_url, {method: 'HEAD'}), |
| 75 {ignoreMethod: true}); |
| 76 }) |
| 77 .then(function(result) { |
| 78 assert_true(result, |
| 79 'Cache.delete should match a non-GET request ' + |
| 80 ' if ignoreMethod is true.') |
74 }); | 81 }); |
75 }, 'Cache.delete called with a HEAD request'); | 82 }, 'Cache.delete called with a HEAD request'); |
76 | 83 |
| 84 cache_test(function(cache) { |
| 85 var vary_request = new Request('http://example.com/c', |
| 86 {headers: {'Cookies': 'is-for-cookie'}}); |
| 87 var vary_response = new Response('', {headers: {'Vary': 'Cookies'}}); |
| 88 var mismatched_vary_request = new Request('http://example.com/c'); |
| 89 |
| 90 return cache.put(vary_request.clone(), vary_response.clone()) |
| 91 .then(function() { |
| 92 return cache.delete(mismatched_vary_request.clone()); |
| 93 }) |
| 94 .then(function(result) { |
| 95 assert_false(result, |
| 96 'Cache.delete should not delete if vary does not ' + |
| 97 'match unless ignoreVary is true'); |
| 98 return cache.delete(mismatched_vary_request.clone(), |
| 99 {ignoreVary: true}); |
| 100 }) |
| 101 .then(function(result) { |
| 102 assert_true(result, |
| 103 'Cache.delete should ignore vary if ignoreVary is true'); |
| 104 }); |
| 105 }, 'Cache.delete supports ignoreVary'); |
77 | 106 |
78 cache_test(function(cache) { | 107 cache_test(function(cache) { |
79 return cache.delete(test_url) | 108 return cache.delete(test_url) |
80 .then(function(result) { | 109 .then(function(result) { |
81 assert_false(result, | 110 assert_false(result, |
82 'Cache.delete should resolve with "false" if there ' + | 111 'Cache.delete should resolve with "false" if there ' + |
83 'are no matching entries.'); | 112 'are no matching entries.'); |
84 }); | 113 }); |
85 }, 'Cache.delete with a non-existent entry'); | 114 }, 'Cache.delete with a non-existent entry'); |
86 | 115 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return cache.matchAll(entries.a_with_query.request, | 155 return cache.matchAll(entries.a_with_query.request, |
127 { ignoreSearch: true }); | 156 { ignoreSearch: true }); |
128 }) | 157 }) |
129 .then(function(result) { | 158 .then(function(result) { |
130 assert_response_array_equivalent(result, [ entries.a.response ]); | 159 assert_response_array_equivalent(result, [ entries.a.response ]); |
131 }); | 160 }); |
132 }, | 161 }, |
133 'Cache.delete with ignoreSearch option (when it is specified as false)'); | 162 'Cache.delete with ignoreSearch option (when it is specified as false)'); |
134 | 163 |
135 done(); | 164 done(); |
OLD | NEW |