invalidate.any.js (5434B)
1 // META: global=window,worker 2 // META: title=HTTP Cache - Invalidation 3 // META: timeout=long 4 // META: script=/common/utils.js 5 // META: script=/common/get-host-info.sub.js 6 // META: script=http-cache.js 7 8 var tests = [ 9 { 10 name: 'HTTP cache invalidates after a successful response from a POST', 11 requests: [ 12 { 13 template: "fresh" 14 }, { 15 request_method: "POST", 16 request_body: "abc" 17 }, { 18 expected_type: "not_cached" 19 } 20 ] 21 }, 22 { 23 name: 'HTTP cache does not invalidate after a failed response from an unsafe request', 24 requests: [ 25 { 26 template: "fresh" 27 }, { 28 request_method: "POST", 29 request_body: "abc", 30 response_status: [500, "Internal Server Error"] 31 }, { 32 expected_type: "cached" 33 } 34 ] 35 }, 36 { 37 name: 'HTTP cache invalidates after a successful response from a PUT', 38 requests: [ 39 { 40 template: "fresh" 41 }, { 42 template: "fresh", 43 request_method: "PUT", 44 request_body: "abc" 45 }, { 46 expected_type: "not_cached" 47 } 48 ] 49 }, 50 { 51 name: 'HTTP cache invalidates after a successful response from a DELETE', 52 requests: [ 53 { 54 template: "fresh" 55 }, { 56 request_method: "DELETE", 57 request_body: "abc" 58 }, { 59 expected_type: "not_cached" 60 } 61 ] 62 }, 63 { 64 name: 'HTTP cache invalidates after a successful response from an unknown method', 65 requests: [ 66 { 67 template: "fresh" 68 }, { 69 request_method: "FOO", 70 request_body: "abc" 71 }, { 72 expected_type: "not_cached" 73 } 74 ] 75 }, 76 77 78 { 79 name: 'HTTP cache invalidates Location URL after a successful response from a POST', 80 requests: [ 81 { 82 template: "location" 83 }, { 84 request_method: "POST", 85 request_body: "abc", 86 template: "lcl_response" 87 }, { 88 template: "location", 89 expected_type: "not_cached" 90 } 91 ] 92 }, 93 { 94 name: 'HTTP cache does not invalidate Location URL after a failed response from an unsafe request', 95 requests: [ 96 { 97 template: "location" 98 }, { 99 template: "lcl_response", 100 request_method: "POST", 101 request_body: "abc", 102 response_status: [500, "Internal Server Error"] 103 }, { 104 template: "location", 105 expected_type: "cached" 106 } 107 ] 108 }, 109 { 110 name: 'HTTP cache invalidates Location URL after a successful response from a PUT', 111 requests: [ 112 { 113 template: "location" 114 }, { 115 template: "lcl_response", 116 request_method: "PUT", 117 request_body: "abc" 118 }, { 119 template: "location", 120 expected_type: "not_cached" 121 } 122 ] 123 }, 124 { 125 name: 'HTTP cache invalidates Location URL after a successful response from a DELETE', 126 requests: [ 127 { 128 template: "location" 129 }, { 130 template: "lcl_response", 131 request_method: "DELETE", 132 request_body: "abc" 133 }, { 134 template: "location", 135 expected_type: "not_cached" 136 } 137 ] 138 }, 139 { 140 name: 'HTTP cache invalidates Location URL after a successful response from an unknown method', 141 requests: [ 142 { 143 template: "location" 144 }, { 145 template: "lcl_response", 146 request_method: "FOO", 147 request_body: "abc" 148 }, { 149 template: "location", 150 expected_type: "not_cached" 151 } 152 ] 153 }, 154 155 156 157 { 158 name: 'HTTP cache invalidates Content-Location URL after a successful response from a POST', 159 requests: [ 160 { 161 template: "content_location" 162 }, { 163 request_method: "POST", 164 request_body: "abc", 165 template: "lcl_response" 166 }, { 167 template: "content_location", 168 expected_type: "not_cached" 169 } 170 ] 171 }, 172 { 173 name: 'HTTP cache does not invalidate Content-Location URL after a failed response from an unsafe request', 174 requests: [ 175 { 176 template: "content_location" 177 }, { 178 template: "lcl_response", 179 request_method: "POST", 180 request_body: "abc", 181 response_status: [500, "Internal Server Error"] 182 }, { 183 template: "content_location", 184 expected_type: "cached" 185 } 186 ] 187 }, 188 { 189 name: 'HTTP cache invalidates Content-Location URL after a successful response from a PUT', 190 requests: [ 191 { 192 template: "content_location" 193 }, { 194 template: "lcl_response", 195 request_method: "PUT", 196 request_body: "abc" 197 }, { 198 template: "content_location", 199 expected_type: "not_cached" 200 } 201 ] 202 }, 203 { 204 name: 'HTTP cache invalidates Content-Location URL after a successful response from a DELETE', 205 requests: [ 206 { 207 template: "content_location" 208 }, { 209 template: "lcl_response", 210 request_method: "DELETE", 211 request_body: "abc" 212 }, { 213 template: "content_location", 214 expected_type: "not_cached" 215 } 216 ] 217 }, 218 { 219 name: 'HTTP cache invalidates Content-Location URL after a successful response from an unknown method', 220 requests: [ 221 { 222 template: "content_location" 223 }, { 224 template: "lcl_response", 225 request_method: "FOO", 226 request_body: "abc" 227 }, { 228 template: "content_location", 229 expected_type: "not_cached" 230 } 231 ] 232 } 233 234 ]; 235 run_tests(tests);