image-referrer-policy.sub.js (972B)
1 function make_test_url(type, policy, expected) { 2 if (type == "cross-origin") 3 return `url("http://{{hosts[][]}}:{{ports[http][1]}}/css/css-values/urls/support/image-referrer-policy.py?expected_referrer=${expected}&origin=${location.origin}/&url=${document.URL}"${policy ? ` referrer-policy(${policy})` : ``})`; 4 if (type == "same-origin") 5 return `url("http://{{hosts[][]}}:{{ports[http][0]}}/css/css-values/urls/support/image-referrer-policy.py?expected_referrer=${expected}&origin=${location.origin}/&url=${document.URL}"${policy ? ` referrer-policy(${policy})` : ``})`; 6 throw `Unknown type: ${type}`; 7 } 8 9 function test_image_referrer_policy(descriptor) { 10 var style = document.createElement("style"); 11 style.innerHTML = ` 12 .test { 13 width: 200px; 14 height: 200px; 15 background-color: blue; 16 background-image: ${make_test_url(descriptor.load_type, descriptor.referrer_policy, descriptor.expected_referrer)}; 17 };`; 18 document.head.append(style); 19 }