test_referrer_header_current_document.html (1398B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test referrer header not affecting document.referrer for current document for Bug 1601743</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 8 <!-- 9 Testing that navigating to a document with Referrer-Policy:same-origin doesn't affect 10 the value of document.referrer for that document. 11 https://bugzilla.mozilla.org/show_bug.cgi?id=1601743 12 --> 13 14 <script type="application/javascript"> 15 function getExpectedReferrer(referrer) { 16 let defaultPolicy = SpecialPowers.getIntPref("network.http.referer.defaultPolicy"); 17 SimpleTest.ok([2, 3].indexOf(defaultPolicy) > -1, "default referrer policy should be either strict-origin-when-cross-origin(2) or no-referrer-when-downgrade(3)"); 18 if (defaultPolicy == 2) { 19 return referrer.match(/https?:\/\/[^\/]+\/?/i)[0]; 20 } 21 return referrer; 22 } 23 const IFRAME_URL = `${location.origin}/tests/dom/security/test/referrer-policy/referrer_header_current_document_iframe.html`; 24 25 SimpleTest.waitForExplicitFinish(); 26 window.addEventListener("message", (event) => { 27 SimpleTest.is(event.data, getExpectedReferrer(IFRAME_URL), "Must have the original iframe as the referrer!"); 28 SimpleTest.finish(); 29 }, { once: true }); 30 </script> 31 </head> 32 33 <body> 34 <iframe src="referrer_header_current_document_iframe.html"></iframe> 35 </body>