diff options
Diffstat (limited to 'testing/web-platform/tests/attribution-reporting/resources/helpers.js')
-rw-r--r-- | testing/web-platform/tests/attribution-reporting/resources/helpers.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/testing/web-platform/tests/attribution-reporting/resources/helpers.js b/testing/web-platform/tests/attribution-reporting/resources/helpers.js index e5c749931e..054df6b972 100644 --- a/testing/web-platform/tests/attribution-reporting/resources/helpers.js +++ b/testing/web-platform/tests/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': |