external-import-stylesheet.html (2050B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>CSS integration - image from imported stylesheet (external)</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 imported stylesheets (loaded from external 14 stylesheets) are loaded with the referrer and referrer policy from the 15 external stylesheet.</p> 16 17 <div class="styled"></div> 18 19 <script> 20 promise_test(function(css_test) { 21 var id = token(); 22 var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + 23 "/common/security-features/subresource/stylesheet.py?id=" + id + 24 "&import-rule" + "&type=image"; 25 var url_prefix = location.protocol + "//" + location.hostname + ":" + location.port; 26 var css_referrer = url_prefix + 27 "/common/security-features/subresource/stylesheet.py?id=" + id + 28 "&type=image"; 29 var img_url = url_prefix + "/common/security-features/subresource/image.py" + 30 "?id=" + id + "&report-headers"; 31 32 return new Promise(resolve => { 33 var link = document.createElement("link"); 34 link.href = css_url; 35 link.rel = "stylesheet"; 36 link.onload = resolve; 37 document.head.appendChild(link); 38 }) 39 .then(() => timeoutPromise(css_test, 1000)) 40 .then(() => requestViaXhr(img_url)) 41 .then(function(message) { 42 assert_own_property(message, "headers"); 43 assert_own_property(message, "referrer"); 44 assert_equals(message.referrer, css_referrer); 45 }); 46 }, "Image from imported stylesheet (external)."); 47 </script> 48 49 <div id="log"></div> 50 </body> 51 </html>