Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<title>Test that reports from different origins are not sent together</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 => {
// Attach a cross-origin iframe which should post back here immediately
// before generating a CSP error. That error should be reported to the
// same endpoint that this frame reports to.
await new Promise(resolve => {
const iframe = document.createElement('iframe');
addEventListener('message', resolve);
// Trigger a CSP error and report in this frame as well.
await new Promise(resolve => {
const img = document.createElement('img');
img.src = "/reporting/resources/fail.png";
img.addEventListener('error', resolve);
// Wait for 2 reports to be received.
const reports = await pollReports(endpoint, id, 2);
assert_equals(reports.length, 2);
// Validate that reports were sent in separate requests.
const request_count = await pollNumResults(endpoint, id);
assert_equals(request_count, 2);
}, "Reports were sent in two requests.");