Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<title>Test that credentials are sent properly in a same-origin and also same-site nested context</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src='resources/report-helper.js'></script>
const base_url = `${location.protocol}//${}`;
const endpoint = `${base_url}/reporting/resources/`;
const id = 'd0d517bf-891b-457a-b970-8b2b2c81a0bf';
promise_test(async t => {
// If this is not run from the expected origin, then the A->A->A frame embedding will not be correct,
// and the cookies set in the top-level page will never be returned with the reports.
"Test running on unexpected origin; subsequent assertions will fail.");
// Set credentials, and set up test to clear them afterwards.
await fetch('/cookies/resources/', {mode: 'no-cors', credentials: 'include', cache: 'no-store'});
t.add_cleanup(() => fetch("/cookies/resources/", {mode: 'no-cors', credentials: 'include', cache: 'no-store'}));
// Insert a same-origin frame which will then frame this origin to
// trigger a CSP error.
const frame = document.createElement('iframe');
// Wait for the inner frame to signal that the report has been generated.
await new Promise(resolve => {
window.addEventListener('message', ev => {
if ( === "done")
const reports = await pollReports(endpoint, 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.");