diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /testing/web-platform/tests/attribution-reporting | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/attribution-reporting')
3 files changed, 64 insertions, 6 deletions
diff --git a/testing/web-platform/tests/attribution-reporting/referrer-policy.sub.https.html b/testing/web-platform/tests/attribution-reporting/referrer-policy.sub.https.html new file mode 100644 index 0000000000..ee4e0c9a8c --- /dev/null +++ b/testing/web-platform/tests/attribution-reporting/referrer-policy.sub.https.html @@ -0,0 +1,56 @@ +<!doctype html> +<meta charset=utf-8> +<meta name=timeout content=long> +<meta name=variant content="?method=a"> +<meta name=variant content="?method=a&noreferrer"> +<meta name=variant content="?method=img"> +<meta name=variant content="?method=img&noreferrer"> +<meta name=variant content="?method=open"> +<meta name=variant content="?method=open&noreferrer"> +<meta name=variant content="?method=script"> +<meta name=variant content="?method=script&noreferrer"> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/helpers.js"></script> +<body> +<script> +const waitForRequest = async () => { + const url = blankURL(); + url.searchParams.set('get-requests', 'true'); + + for (let i = 0; i < 20; i++) { + const resp = await fetch(url); + const payload = await resp.json(); + if (payload !== null && payload.length > 0) { + return payload; + } + await delay(100); + } + throw new Error('Timeout polling requests'); +}; + +const searchParams = new URLSearchParams(location.search); + +promise_test(async t => { + const noreferrer = searchParams.has('noreferrer'); + + await registerAttributionSrc({ + method: 'variant', + extraQueryParams: {'store-request': 'true'}, + referrerPolicy: noreferrer ? 'no-referrer' : '', + }); + + const requests = await waitForRequest(); + assert_equals(requests.length, 1); + + if (noreferrer) { + assert_not_own_property(requests[0], 'referer'); + } else { + assert_own_property(requests[0], 'referer'); + assert_equals(requests[0].referer, location.toString()); + } + +}, 'attributionsrc referrer policy is propagated.'); +</script> diff --git a/testing/web-platform/tests/attribution-reporting/request-format.sub.https.html b/testing/web-platform/tests/attribution-reporting/request-format.sub.https.html index a9e36dd126..83a2d8f6bd 100644 --- a/testing/web-platform/tests/attribution-reporting/request-format.sub.https.html +++ b/testing/web-platform/tests/attribution-reporting/request-format.sub.https.html @@ -53,9 +53,7 @@ promise_test(async t => { } 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/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': |