external-stylesheet.html (1735B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>CSS integration - image from external stylesheet</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/common/utils.js"></script> 8 <!-- Common global functions for referrer-policy tests. --> 9 <script src="/common/security-features/resources/common.sub.js"></script> 10 <meta name="referrer" content="never"> 11 </head> 12 <body> 13 <p>Check that resources from external stylesheets are loaded with 14 the referrer and referrer policy from the external stylesheet.</p> 15 16 <div class="styled"></div> 17 18 <script> 19 promise_test(function(css_test) { 20 var id = token(); 21 var url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port; 22 var css_url = url_prefix + "/common/security-features/subresource/stylesheet.py?id=" + id; 23 var img_url = url_prefix + "/common/security-features/subresource/image.py" + 24 "?id=" + id + "&report-headers"; 25 26 return new Promise(resolve => { 27 var link = document.createElement("link"); 28 link.href = css_url; 29 link.rel = "stylesheet"; 30 link.onload = resolve; 31 document.head.appendChild(link); 32 }) 33 .then(() => timeoutPromise(css_test, 1000)) 34 .then(() => requestViaXhr(img_url)) 35 .then(function(message) { 36 assert_own_property(message, "headers"); 37 assert_own_property(message, "referrer"); 38 assert_equals(message.referrer, css_url); 39 }); 40 }, "Image from external stylesheet."); 41 </script> 42 43 <div id="log"></div> 44 </body> 45 </html>