assign-replace-from-top-to-nested-iframe.html (1576B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Referer with location.replace and location.assign with nested iframes</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <iframe src="resources/iframe-with-iframe.html" hidden></iframe> 10 <script> 11 const iframe = document.querySelector("iframe"); 12 async_test(function(t) { 13 function on_message(e) { 14 const referrer = e.data; 15 assert_equals(referrer, iframe.contentWindow.location.href); 16 t.done(); 17 } 18 window.addEventListener('message', t.step_func(on_message), false); 19 window.addEventListener('load', function () { 20 iframe.contentDocument.querySelector("iframe").contentWindow.location.replace("/resources/blank.html"); 21 }, false); 22 }, "Browser sends Referer header in nested iframe request when location.replace is called on an iframe"); 23 async_test(function(t) { 24 function on_message(e) { 25 const referrer = e.data; 26 assert_equals(referrer, iframe.contentWindow.location.href); 27 t.done(); 28 } 29 window.addEventListener('message', t.step_func(on_message), false); 30 window.addEventListener('load', function () { 31 iframe.contentDocument.querySelector("iframe").contentWindow.location.replace("/resources/blank.html"); 32 }, false); 33 }, "Browser sends Referer header in nested iframe request when location.assign is called on an iframe"); 34 </script> 35 </body> 36 </html>