Files
sousa-gecko/testing/web-platform/tests/reporting/cross-origin-same-site-credentials.https.sub.html
T
Jonathan Lee 76c422f3b9 Bug 1923975 [wpt PR 48570] - [reporting][wpt] Isolate stashed reports, a=testonly
Automatic update from web-platform-tests
[reporting][wpt] Isolate stashed reports

Several `reporting/` tests use the same wptserve stash entry (report ID
`d0d517bf-891b-457a-b970-8b2b2c81a0bf` [0]). If at least two such tests
are unlucky enough to run in parallel, the first one to poll `report.py`
will cannibalize all of the reports and get too many, while the others
will get too few.

Fix this by regenerating different IDs for all but one of the tests. For
the external WPTs that embed on `middle-frame.https.sub.html`, plumb the
report ID to `same-origin-report.https.sub.html` as a query parameter,
where it can be substituted into the `Reporting-Endpoints` response
header [1].

Continue using hardcoded IDs instead of randomly generated ones so that
reports can be matched with their tests.

[0]: https://source.chromium.org/search?q=d0d517bf-891b-457a-b970-8b2b2c81a0bf%20f:wpt%20&ss=chromium%2Fchromium%2Fsrc
[1]: https://web-platform-tests.org/writing-tests/server-pipes.html#sub

Bug: 338470458
Test: run_web_tests.py external/wpt/reporting wpt_internal/reporting --fully-parallel -j 36
Change-Id: I46d4d9de954d853615b067725a136a65a6df622b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5922396
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Commit-Queue: Jonathan Lee <jonathanjlee@google.com>
Cr-Commit-Position: refs/heads/main@{#1367116}

--

wpt-commits: 3e0163f8505cac8a369aab811179cc9dc0f60ebe
wpt-pr: 48570
2024-10-14 09:15:05 +00:00

56 lines
2.9 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test that credentials are sent properly in a cross-origin but same-site nested 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 = 'd6f382f4-028d-51e0-9ef2-a635439da02a';
promise_test(async t => {
// If this is not run from the expected origin, then the A->A->www.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. Cookies are set with the Domain
// attribute, so that they may be sent to same-site resources.
await fetch('/cookies/resources/setSameSiteDomain.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 same-origin frame, which will then frame a same-site but cross-origin page to
// trigger a CSP error.
const frame = document.createElement('iframe');
frame.src = `https://{{hosts[][]}}:{{ports[https][0]}}/reporting/resources/middle-frame.https.sub.html?host={{hosts[][www]}}&reportID=${id}`;
// 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[][www]}}:{{ports[https][0]}}/reporting/resources/same-origin-report.https.sub.html?reportID=${id}`);
// All credentials set at the top-level should be received.
const cookies = await pollCookies(endpoint, id);
assert_equals(cookies.samesite_none, "[samesite_none=reporting]", "Credential value was correct");
assert_equals(cookies.samesite_unspecified, "[samesite_unspecified=reporting]", "Credential value was correct");
assert_equals(cookies.samesite_lax, "[samesite_lax=reporting]", "Credential value was correct");
assert_equals(cookies.samesite_strict, "[samesite_strict=reporting]", "Credential value was correct");
assert_equals(Object.keys(cookies).length, 4, "No additional cookies were received");
}, "Reporting endpoints received credentials.");
</script>
</body>
</html>