iframe-inheritance-srcdoc.html (1774B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Referrer Policy: iframes srdoc correctly inherit the ancestor's referrer policy</title> 5 <link rel="help" href="https://www.w3.org/TR/referrer-policy/#referrer-policy-delivery-nested"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/common/get-host-info.sub.js"></script> 9 <script src="resources/make-html-script.js"></script> 10 <meta name="referrer" content="origin"> 11 </head> 12 <body> 13 <h1>Referrer Policy: iframes srcdoc correctly inherit the ancestor's referrer policy</h1> 14 <script> 15 let reportedReferrer = () => { 16 return new Promise(resolve => { 17 window.addEventListener("message", msg => resolve(msg.data.referrer)); 18 }); 19 }; 20 21 const iframe = document.createElement("iframe"); 22 23 promise_test(async t => { 24 let referrer = reportedReferrer(); 25 iframe.srcdoc = createScriptString(get_host_info().REMOTE_ORIGIN, 26 location.origin + "/custom"); 27 document.body.appendChild(iframe); 28 assert_equals(await referrer, self.origin + "/", 29 "Referrer policy should be inherited from parent."); 30 31 let meta = document.createElement('meta'); 32 meta.name = "referrer"; 33 meta.content = "unsafe-url"; 34 document.head.appendChild(meta); 35 iframe.contentWindow.postMessage('checkReferrer'); 36 assert_equals( 37 await reportedReferrer(), self.origin + "/", 38 "Changing parent's referrer policy has no effect on the child."); 39 40 }, "Srcdoc iframe inherits referrer policy from parent on creation."); 41 42 </script> 43 <div id="log"></div> 44 </body> 45 </html>