prefetch-headers.https.html (1374B)
1 <!DOCTYPE html> 2 <title>Ensures that prefetch sends headers as per-spec</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="resources/prefetch-helper.js"></script> 7 <body> 8 <script> 9 10 promise_test(async t => { 11 const {href} = await prefetch({"type": "image/png", file: "green.png"}, t); 12 const [info] = await get_prefetch_info(href); 13 const {headers} = info; 14 assert_equals(headers["sec-fetch-dest"], "empty"); 15 assert_equals(headers["sec-purpose"], "prefetch"); 16 assert_false("origin" in headers); 17 }, "Prefetch should include Sec-Purpose=prefetch and Sec-Fetch-Dest=empty headers"); 18 19 promise_test(async t => { 20 const {href} = await prefetch({"type": "image/png", file: "green.png"}, t); 21 const [info] = await get_prefetch_info(href); 22 const {headers} = info; 23 assert_false("purpose" in headers); 24 assert_false("x-moz" in headers); 25 }, "Prefetch should not include proprietary headers (X-moz/Purpose)"); 26 27 promise_test(async t => { 28 const {href} = await prefetch({"type": "image/png", file: "green.png", crossOrigin: "anonymous"}, t); 29 const [info] = await get_prefetch_info(href); 30 const {headers} = info; 31 assert_equals(headers["origin"], document.origin); 32 }, "Prefetch should respect CORS mode"); 33 34 </script> 35 </body>