diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/reporting/same-origin-cross-site-credentials.https.sub.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/reporting/same-origin-cross-site-credentials.https.sub.html')
-rw-r--r-- | testing/web-platform/tests/reporting/same-origin-cross-site-credentials.https.sub.html | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/web-platform/tests/reporting/same-origin-cross-site-credentials.https.sub.html b/testing/web-platform/tests/reporting/same-origin-cross-site-credentials.https.sub.html new file mode 100644 index 0000000000..258ab8e103 --- /dev/null +++ b/testing/web-platform/tests/reporting/same-origin-cross-site-credentials.https.sub.html @@ -0,0 +1,53 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test that credentials are sent properly in a same-origin but not same-site context</title> + <script src='/resources/testharness.js'></script> + <script src='/resources/testharnessreport.js'></script> + <script src='resources/report-helper.js'></script> +</head> +<body> + <script> + const base_url = `${location.protocol}//${location.host}`; + const endpoint = `${base_url}/reporting/resources/report.py`; + const id = 'd0d517bf-891b-457a-b970-8b2b2c81a0bf'; + + promise_test(async t => { + // If this is not run from the expected origin, then the A->B->A frame embedding will not be correct, + // and the cookies set in the top-level page will never be returned with the reports. + assert_true(location.href.startsWith("https://{{hosts[][]}}:{{ports[https][0]}}/"), + "Test running on unexpected origin; subsequent assertions will fail."); + + // Set credentials, and set up test to clear them afterwards. + await fetch('/cookies/resources/setSameSite.py?reporting', {mode: 'no-cors', credentials: 'include', cache: 'no-store'}); + t.add_cleanup(() => fetch("/cookies/resources/dropSameSite.py", {mode: 'no-cors', credentials: 'include', cache: 'no-store'})); + + // Insert a cross-origin frame which will then frame this origin to + // trigger a CSP error. + const frame = document.createElement('iframe'); + frame.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/reporting/resources/middle-frame.https.sub.html"; + document.body.appendChild(frame); + + // Wait for the inner frame to signal that the report has been generated. + await new Promise(resolve => { + window.addEventListener('message', ev => { + if (ev.data === "done") + resolve(ev.data); + }); + document.body.appendChild(frame); + }); + + const reports = await pollReports(endpoint, id); + checkReportExists(reports, 'csp-violation', "https://{{hosts[][]}}:{{ports[https][0]}}/reporting/resources/same-origin-report.https.sub.html"); + + // Same-site: None cookies should be sent, but not Lax, Strict, or default cookies. + const cookies = await pollCookies(endpoint, id); + assert_equals(cookies.samesite_none, "[samesite_none=reporting]", "Credential value was correct"); + assert_false("samesite_strict" in cookies, "Same-site: Strict cookies should not be sent"); + assert_false("samesite_lax" in cookies, "Same-site: Lax cookies should not be sent"); + assert_false("samesite_unspecified" in cookies, "Same-site unspecified cookies should not be sent"); + assert_equals(Object.keys(cookies).length, 1, "No additional cookies were received"); + }, "Reporting endpoints received credentials."); + </script> +</body> +</html> |