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