|
| 1 | +<!DOCTYPE html> |
| 2 | +<!-- |
| 3 | +This test was procedurally generated. Please do not modify it directly. |
| 4 | +Sources: |
| 5 | +- fetch/metadata/tools/fetch-metadata.conf.yml |
| 6 | +- fetch/metadata/tools/templates/script-json-module-import-static.sub.html |
| 7 | +--> |
| 8 | +<html lang="en"> |
| 9 | + <meta charset="utf-8"> |
| 10 | + <title>HTTP headers on request for static ECMAScript module import</title> |
| 11 | + <script src="/resources/testharness.js"></script> |
| 12 | + <script src="/resources/testharnessreport.js"></script> |
| 13 | + <script src="/fetch/metadata/resources/helper.sub.js"></script> |
| 14 | + <body> |
| 15 | + <script> |
| 16 | + 'use strict'; |
| 17 | + |
| 18 | + function induceRequest(url) { |
| 19 | + const script = document.createElement('script'); |
| 20 | + script.setAttribute('type', 'module'); |
| 21 | + script.setAttribute( |
| 22 | + 'src', |
| 23 | + '/fetch/metadata/resources/es-json-module.sub.js?moduleId=' + encodeURIComponent(url) |
| 24 | + ); |
| 25 | + |
| 26 | + return new Promise((resolve, reject) => { |
| 27 | + script.onload = resolve; |
| 28 | + script.onerror = () => reject('Failed to load script'); |
| 29 | + document.body.appendChild(script); |
| 30 | + }) |
| 31 | + .then(() => script.remove()); |
| 32 | + } |
| 33 | + |
| 34 | + promise_test(() => { |
| 35 | + const key = '{{uuid()}}'; |
| 36 | + |
| 37 | + return induceRequest( |
| 38 | + makeRequestURL( |
| 39 | + key, |
| 40 | + ['httpsOrigin'], |
| 41 | + { |
| 42 | + mime: 'application/json', |
| 43 | + body: '{}' |
| 44 | + } |
| 45 | + ) |
| 46 | + ) |
| 47 | + .then(() => retrieve(key)) |
| 48 | + .then((headers) => { |
| 49 | + assert_own_property(headers, 'sec-fetch-site'); |
| 50 | + assert_array_equals(headers['sec-fetch-site'], ['same-origin']); |
| 51 | + }); |
| 52 | + }, 'sec-fetch-site - Same origin'); |
| 53 | + |
| 54 | + promise_test(() => { |
| 55 | + const key = '{{uuid()}}'; |
| 56 | + |
| 57 | + return induceRequest( |
| 58 | + makeRequestURL( |
| 59 | + key, |
| 60 | + ['httpsCrossSite'], |
| 61 | + { |
| 62 | + mime: 'application/json', |
| 63 | + body: '{}' |
| 64 | + } |
| 65 | + ) |
| 66 | + ) |
| 67 | + .then(() => retrieve(key)) |
| 68 | + .then((headers) => { |
| 69 | + assert_own_property(headers, 'sec-fetch-site'); |
| 70 | + assert_array_equals(headers['sec-fetch-site'], ['cross-site']); |
| 71 | + }); |
| 72 | + }, 'sec-fetch-site - Cross-site'); |
| 73 | + |
| 74 | + promise_test(() => { |
| 75 | + const key = '{{uuid()}}'; |
| 76 | + |
| 77 | + return induceRequest( |
| 78 | + makeRequestURL( |
| 79 | + key, |
| 80 | + ['httpsSameSite'], |
| 81 | + { |
| 82 | + mime: 'application/json', |
| 83 | + body: '{}' |
| 84 | + } |
| 85 | + ) |
| 86 | + ) |
| 87 | + .then(() => retrieve(key)) |
| 88 | + .then((headers) => { |
| 89 | + assert_own_property(headers, 'sec-fetch-site'); |
| 90 | + assert_array_equals(headers['sec-fetch-site'], ['same-site']); |
| 91 | + }); |
| 92 | + }, 'sec-fetch-site - Same site'); |
| 93 | + |
| 94 | + promise_test(() => { |
| 95 | + const key = '{{uuid()}}'; |
| 96 | + |
| 97 | + return induceRequest( |
| 98 | + makeRequestURL( |
| 99 | + key, |
| 100 | + ['httpsOrigin', 'httpsCrossSite', 'httpsOrigin'], |
| 101 | + { |
| 102 | + mime: 'application/json', |
| 103 | + body: '{}' |
| 104 | + } |
| 105 | + ) |
| 106 | + ) |
| 107 | + .then(() => retrieve(key)) |
| 108 | + .then((headers) => { |
| 109 | + assert_own_property(headers, 'sec-fetch-site'); |
| 110 | + assert_array_equals(headers['sec-fetch-site'], ['cross-site']); |
| 111 | + }); |
| 112 | + }, 'sec-fetch-site - Same-Origin -> Cross-Site -> Same-Origin redirect'); |
| 113 | + |
| 114 | + promise_test(() => { |
| 115 | + const key = '{{uuid()}}'; |
| 116 | + |
| 117 | + return induceRequest( |
| 118 | + makeRequestURL( |
| 119 | + key, |
| 120 | + ['httpsOrigin', 'httpsSameSite', 'httpsOrigin'], |
| 121 | + { |
| 122 | + mime: 'application/json', |
| 123 | + body: '{}' |
| 124 | + } |
| 125 | + ) |
| 126 | + ) |
| 127 | + .then(() => retrieve(key)) |
| 128 | + .then((headers) => { |
| 129 | + assert_own_property(headers, 'sec-fetch-site'); |
| 130 | + assert_array_equals(headers['sec-fetch-site'], ['same-site']); |
| 131 | + }); |
| 132 | + }, 'sec-fetch-site - Same-Origin -> Same-Site -> Same-Origin redirect'); |
| 133 | + |
| 134 | + promise_test(() => { |
| 135 | + const key = '{{uuid()}}'; |
| 136 | + |
| 137 | + return induceRequest( |
| 138 | + makeRequestURL( |
| 139 | + key, |
| 140 | + ['httpsCrossSite', 'httpsOrigin'], |
| 141 | + { |
| 142 | + mime: 'application/json', |
| 143 | + body: '{}' |
| 144 | + } |
| 145 | + ) |
| 146 | + ) |
| 147 | + .then(() => retrieve(key)) |
| 148 | + .then((headers) => { |
| 149 | + assert_own_property(headers, 'sec-fetch-site'); |
| 150 | + assert_array_equals(headers['sec-fetch-site'], ['cross-site']); |
| 151 | + }); |
| 152 | + }, 'sec-fetch-site - Cross-Site -> Same Origin'); |
| 153 | + |
| 154 | + promise_test(() => { |
| 155 | + const key = '{{uuid()}}'; |
| 156 | + |
| 157 | + return induceRequest( |
| 158 | + makeRequestURL( |
| 159 | + key, |
| 160 | + ['httpsCrossSite', 'httpsSameSite'], |
| 161 | + { |
| 162 | + mime: 'application/json', |
| 163 | + body: '{}' |
| 164 | + } |
| 165 | + ) |
| 166 | + ) |
| 167 | + .then(() => retrieve(key)) |
| 168 | + .then((headers) => { |
| 169 | + assert_own_property(headers, 'sec-fetch-site'); |
| 170 | + assert_array_equals(headers['sec-fetch-site'], ['cross-site']); |
| 171 | + }); |
| 172 | + }, 'sec-fetch-site - Cross-Site -> Same-Site'); |
| 173 | + |
| 174 | + promise_test(() => { |
| 175 | + const key = '{{uuid()}}'; |
| 176 | + |
| 177 | + return induceRequest( |
| 178 | + makeRequestURL( |
| 179 | + key, |
| 180 | + ['httpsCrossSite', 'httpsCrossSite'], |
| 181 | + { |
| 182 | + mime: 'application/json', |
| 183 | + body: '{}' |
| 184 | + } |
| 185 | + ) |
| 186 | + ) |
| 187 | + .then(() => retrieve(key)) |
| 188 | + .then((headers) => { |
| 189 | + assert_own_property(headers, 'sec-fetch-site'); |
| 190 | + assert_array_equals(headers['sec-fetch-site'], ['cross-site']); |
| 191 | + }); |
| 192 | + }, 'sec-fetch-site - Cross-Site -> Cross-Site'); |
| 193 | + |
| 194 | + promise_test(() => { |
| 195 | + const key = '{{uuid()}}'; |
| 196 | + |
| 197 | + return induceRequest( |
| 198 | + makeRequestURL( |
| 199 | + key, |
| 200 | + ['httpsOrigin', 'httpsOrigin'], |
| 201 | + { |
| 202 | + mime: 'application/json', |
| 203 | + body: '{}' |
| 204 | + } |
| 205 | + ) |
| 206 | + ) |
| 207 | + .then(() => retrieve(key)) |
| 208 | + .then((headers) => { |
| 209 | + assert_own_property(headers, 'sec-fetch-site'); |
| 210 | + assert_array_equals(headers['sec-fetch-site'], ['same-origin']); |
| 211 | + }); |
| 212 | + }, 'sec-fetch-site - Same-Origin -> Same Origin'); |
| 213 | + |
| 214 | + promise_test(() => { |
| 215 | + const key = '{{uuid()}}'; |
| 216 | + |
| 217 | + return induceRequest( |
| 218 | + makeRequestURL( |
| 219 | + key, |
| 220 | + ['httpsOrigin', 'httpsSameSite'], |
| 221 | + { |
| 222 | + mime: 'application/json', |
| 223 | + body: '{}' |
| 224 | + } |
| 225 | + ) |
| 226 | + ) |
| 227 | + .then(() => retrieve(key)) |
| 228 | + .then((headers) => { |
| 229 | + assert_own_property(headers, 'sec-fetch-site'); |
| 230 | + assert_array_equals(headers['sec-fetch-site'], ['same-site']); |
| 231 | + }); |
| 232 | + }, 'sec-fetch-site - Same-Origin -> Same-Site'); |
| 233 | + |
| 234 | + promise_test(() => { |
| 235 | + const key = '{{uuid()}}'; |
| 236 | + |
| 237 | + return induceRequest( |
| 238 | + makeRequestURL( |
| 239 | + key, |
| 240 | + ['httpsOrigin', 'httpsCrossSite'], |
| 241 | + { |
| 242 | + mime: 'application/json', |
| 243 | + body: '{}' |
| 244 | + } |
| 245 | + ) |
| 246 | + ) |
| 247 | + .then(() => retrieve(key)) |
| 248 | + .then((headers) => { |
| 249 | + assert_own_property(headers, 'sec-fetch-site'); |
| 250 | + assert_array_equals(headers['sec-fetch-site'], ['cross-site']); |
| 251 | + }); |
| 252 | + }, 'sec-fetch-site - Same-Origin -> Cross-Site'); |
| 253 | + |
| 254 | + promise_test(() => { |
| 255 | + const key = '{{uuid()}}'; |
| 256 | + |
| 257 | + return induceRequest( |
| 258 | + makeRequestURL( |
| 259 | + key, |
| 260 | + ['httpsSameSite', 'httpsOrigin'], |
| 261 | + { |
| 262 | + mime: 'application/json', |
| 263 | + body: '{}' |
| 264 | + } |
| 265 | + ) |
| 266 | + ) |
| 267 | + .then(() => retrieve(key)) |
| 268 | + .then((headers) => { |
| 269 | + assert_own_property(headers, 'sec-fetch-site'); |
| 270 | + assert_array_equals(headers['sec-fetch-site'], ['same-site']); |
| 271 | + }); |
| 272 | + }, 'sec-fetch-site - Same-Site -> Same Origin'); |
| 273 | + |
| 274 | + promise_test(() => { |
| 275 | + const key = '{{uuid()}}'; |
| 276 | + |
| 277 | + return induceRequest( |
| 278 | + makeRequestURL( |
| 279 | + key, |
| 280 | + ['httpsSameSite', 'httpsSameSite'], |
| 281 | + { |
| 282 | + mime: 'application/json', |
| 283 | + body: '{}' |
| 284 | + } |
| 285 | + ) |
| 286 | + ) |
| 287 | + .then(() => retrieve(key)) |
| 288 | + .then((headers) => { |
| 289 | + assert_own_property(headers, 'sec-fetch-site'); |
| 290 | + assert_array_equals(headers['sec-fetch-site'], ['same-site']); |
| 291 | + }); |
| 292 | + }, 'sec-fetch-site - Same-Site -> Same-Site'); |
| 293 | + |
| 294 | + promise_test(() => { |
| 295 | + const key = '{{uuid()}}'; |
| 296 | + |
| 297 | + return induceRequest( |
| 298 | + makeRequestURL( |
| 299 | + key, |
| 300 | + ['httpsSameSite', 'httpsCrossSite'], |
| 301 | + { |
| 302 | + mime: 'application/json', |
| 303 | + body: '{}' |
| 304 | + } |
| 305 | + ) |
| 306 | + ) |
| 307 | + .then(() => retrieve(key)) |
| 308 | + .then((headers) => { |
| 309 | + assert_own_property(headers, 'sec-fetch-site'); |
| 310 | + assert_array_equals(headers['sec-fetch-site'], ['cross-site']); |
| 311 | + }); |
| 312 | + }, 'sec-fetch-site - Same-Site -> Cross-Site'); |
| 313 | + |
| 314 | + promise_test(() => { |
| 315 | + const key = '{{uuid()}}'; |
| 316 | + |
| 317 | + return induceRequest( |
| 318 | + makeRequestURL( |
| 319 | + key, |
| 320 | + [], |
| 321 | + { |
| 322 | + mime: 'application/json', |
| 323 | + body: '{}' |
| 324 | + } |
| 325 | + ) |
| 326 | + ) |
| 327 | + .then(() => retrieve(key)) |
| 328 | + .then((headers) => { |
| 329 | + assert_own_property(headers, 'sec-fetch-mode'); |
| 330 | + assert_array_equals(headers['sec-fetch-mode'], ['cors']); |
| 331 | + }); |
| 332 | + }, 'sec-fetch-mode'); |
| 333 | + |
| 334 | + promise_test(() => { |
| 335 | + const key = '{{uuid()}}'; |
| 336 | + |
| 337 | + return induceRequest( |
| 338 | + makeRequestURL( |
| 339 | + key, |
| 340 | + [], |
| 341 | + { |
| 342 | + mime: 'application/json', |
| 343 | + body: '{}' |
| 344 | + } |
| 345 | + ) |
| 346 | + ) |
| 347 | + .then(() => retrieve(key)) |
| 348 | + .then((headers) => { |
| 349 | + assert_own_property(headers, 'sec-fetch-dest'); |
| 350 | + assert_array_equals(headers['sec-fetch-dest'], ['json']); |
| 351 | + }); |
| 352 | + }, 'sec-fetch-dest'); |
| 353 | + |
| 354 | + promise_test(() => { |
| 355 | + const key = '{{uuid()}}'; |
| 356 | + |
| 357 | + return induceRequest( |
| 358 | + makeRequestURL( |
| 359 | + key, |
| 360 | + [], |
| 361 | + { |
| 362 | + mime: 'application/json', |
| 363 | + body: '{}' |
| 364 | + } |
| 365 | + ) |
| 366 | + ) |
| 367 | + .then(() => retrieve(key)) |
| 368 | + .then((headers) => { |
| 369 | + assert_not_own_property(headers, 'sec-fetch-user'); |
| 370 | + }); |
| 371 | + }, 'sec-fetch-user'); |
| 372 | + </script> |
| 373 | +</html> |
0 commit comments