iframe-loading-lazy-referrerpolicy-change.sub.html (1991B)
1 <!DOCTYPE html> 2 <head> 3 <title>Deferred loading=lazy iframes are fetched with the parse-time 4 `referrerpolicy` attribute</title> 5 <link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org"> 6 <link rel="author" title="Raj T" href="mailto:rajendrant@chromium.org"> 7 <link rel="help" href="https://github.com/scott-little/lazyload"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="../resources/common.js"></script> 11 </head> 12 13 <script> 14 const below_viewport_iframe = new ElementLoadPromise("below_viewport_iframe"); 15 16 async_test(function(t) { 17 // Change the referrer-policy and scroll down to load the deferred elements. 18 window.addEventListener("load", t.step_func(() => { 19 below_viewport_iframe.element().referrerPolicy = "no-referrer"; 20 below_viewport_iframe.element().scrollIntoView(); 21 })); 22 23 below_viewport_iframe.promise.then( 24 t.step_func_done(function() { 25 // The `Referer` header should be the full URL, as specified by the 26 // iframe's `referrerpolicy` attribute at parse-time, and not the origin 27 // (as specified in meta referrer tag) or null (as overridden 28 // referrerpolicy=no-referrer after load deferral). 29 assert_true(below_viewport_iframe.element().contentDocument.body.innerHTML 30 .includes("Referer: http://{{location[host]}}{{location[path]}}"), 31 "The iframe's `Referer` should be the referrer's full URL"); 32 })); 33 }, "Test that when a deferred iframe is fetched, it uses the " + 34 "`referrerpolicy` specified at parse-time"); 35 </script> 36 37 <body> 38 <meta name="referrer" content="origin"> 39 <div style="height:1000vh;"></div> 40 <iframe id="below_viewport_iframe" src="/xhr/resources/echo-headers.py" 41 loading="lazy" width="200px" height="100px" 42 referrerpolicy="unsafe-url" 43 onload="below_viewport_iframe.resolve();"> 44 </iframe> 45 </body>