diff --git a/attribution-reporting/referrer-policy.sub.https.html b/attribution-reporting/referrer-policy.sub.https.html new file mode 100644 index 00000000000000..ee4e0c9a8c1e54 --- /dev/null +++ b/attribution-reporting/referrer-policy.sub.https.html @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + diff --git a/attribution-reporting/request-format.sub.https.html b/attribution-reporting/request-format.sub.https.html index a9e36dd126771f..83a2d8f6bdfe78 100644 --- a/attribution-reporting/request-format.sub.https.html +++ b/attribution-reporting/request-format.sub.https.html @@ -53,9 +53,7 @@ } else { assert_not_own_property(requests[0], 'attribution-reporting-eligible'); } - assert_equals(requests[0].referer, location.toString()); - // TODO(apaseltiner): Test various referrer policies. // TODO(apaseltiner): Test cookie propagation. const expectedURL = blankURL(); diff --git a/attribution-reporting/resources/helpers.js b/attribution-reporting/resources/helpers.js index e5c749931e03c2..054df6b97295a5 100644 --- a/attribution-reporting/resources/helpers.js +++ b/attribution-reporting/resources/helpers.js @@ -171,6 +171,7 @@ const registerAttributionSrc = async ({ extraQueryParams = {}, reportingOrigin, extraHeaders = [], + referrerPolicy = '', }) => { const searchParams = new URLSearchParams(location.search); @@ -201,7 +202,6 @@ const registerAttributionSrc = async ({ headers.push({name, value: cookie}); } - let credentials; if (method === 'fetch') { const params = getFetchParams(reportingOrigin, cookie); @@ -219,6 +219,7 @@ const registerAttributionSrc = async ({ switch (method) { case 'img': const img = document.createElement('img'); + img.referrerPolicy = referrerPolicy; if (eligible === null) { img.attributionSrc = url; } else { @@ -236,6 +237,7 @@ const registerAttributionSrc = async ({ return 'event'; case 'script': const script = document.createElement('script'); + script.referrerPolicy = referrerPolicy; if (eligible === null) { script.attributionSrc = url; } else { @@ -249,6 +251,7 @@ const registerAttributionSrc = async ({ return 'event'; case 'a': const a = document.createElement('a'); + a.referrerPolicy = referrerPolicy; a.target = '_blank'; a.textContent = 'link'; if (eligible === null) { @@ -263,12 +266,13 @@ const registerAttributionSrc = async ({ return 'navigation'; case 'open': await test_driver.bless('open window', () => { + const feature = referrerPolicy === 'no-referrer' ? 'noreferrer' : ''; if (eligible === null) { open( blankURL(), '_blank', - `attributionsrc=${encodeURIComponent(url)}`); + `attributionsrc=${encodeURIComponent(url)} ${feature}`); } else { - open(url, '_blank', 'attributionsrc'); + open(url, '_blank', `attributionsrc ${feature}`); } }); return 'navigation'; @@ -277,7 +281,7 @@ const registerAttributionSrc = async ({ if (eligible !== null) { attributionReporting = JSON.parse(eligible); } - await fetch(url, {credentials, attributionReporting}); + await fetch(url, {credentials, attributionReporting, referrerPolicy}); return 'event'; } case 'xhr':