Files
firefox/testing/web-platform/tests/reporting/cross-origin-reports-isolated.https.sub.html
Brent Fulgham 58fbbb332b Bug 1796860 [wpt PR 36605] - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=246887, a=testonly
Automatic update from web-platform-tests
WebKit export of https://bugs.webkit.org/show_bug.cgi?id=246887 (#36605)

[WPT] Remove some 3-second sleeps in test cases
https://commits.webkit.org/255885@main
--

wpt-commits: d3ab8c1e063cd58a58914fac54584a180640b565
wpt-pr: 36605
2022-11-07 10:54:08 +00:00

46 lines
1.7 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<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>
</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 => {
// 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');
iframe.src = "https://{{domains[www]}}:{{ports[https][0]}}/reporting/resources/csp-error.https.sub.html";
addEventListener('message', resolve);
document.body.appendChild(iframe);
});
// 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);
document.body.appendChild(img);
});
// 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.");
</script>
</body>
</html>