Files
firefox/testing/web-platform/tests/reporting/document-reporting-not-batch-different-document.https.html
T
Rodney Ding 8c34bdc921 Bug 1724214 [wpt PR 29913] - Add wpt tests for Document-Reporting Endpoints header, a=testonly
Automatic update from web-platform-tests
Add wpt tests for Document-Reporting Endpoints header

- These tests describe the desired behaviour according to the spec
- This includes the following cases:
  1) Sending reports to default endpoint
  2) Setting Reporting-Endpoints header with path-absolute url
  3) Sending reports to multiple named endpoints
  4) Endpoint with the same name gets overridden
  5) Document has both Report-To and Reporting-Endpoints header
  6) Reports are not batched for same endpoint, same url in two frame
  7) Reports are not sent after navigating from document with
     Reporting-Endpoints header to same url without header
- Update uuid used in various Reporting-Endpoints header's reportID so
  they're actually unique among tests.

Bug: 1062359
Change-Id: I42f268e8421407d3f9b745b7d762c4775f247500
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3060743
Commit-Queue: Rodney Ding <[email protected]>
Reviewed-by: Ian Clelland <[email protected]>
Cr-Commit-Position: refs/heads/main@{#924487}

--

wpt-commits: f5d9b675bc878e6b2eee7d54fe36a7b9237a8092
wpt-pr: 29913
2021-10-04 00:20:20 +00:00

36 lines
1.5 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test that reports are sent to multiple named endpoints</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src='resources/report-helper.js'></script>
</head>
<body>
<iframe name="report1"></iframe>
<iframe name="report2"></iframe>
<script>
const base_url = `${location.protocol}//${location.host}`;
const endpoint = `${base_url}/reporting/resources/report.py`;
const report_id = '204d2fb2-018b-4e35-964c-5e298e89d4e2';
promise_test(async t => {
const w = window.open(`resources/generate-report.https.sub.html?pipe=header(Reporting-Endpoints,default="/reporting/resources/report.py?reportID=${report_id}")`, "report1");
const w2 = window.open(`resources/generate-csp-report.https.sub.html?pipe=header(Reporting-Endpoints,default="/reporting/resources/report.py?reportID=${report_id}")`, "report2");
await wait(3000);
// Verify that each iframe generated and sent one report.
const reports = await pollReports(endpoint, report_id);
assert_equals(reports.length, 2, "Number of reports");
checkReportExists(reports, 'deprecation', w.location.href);
checkReportExists(reports, 'csp-violation', w2.location.href);
const request_count = await pollNumResults(endpoint, report_id);
// Verify that requests are sent separately.
assert_equals(request_count, 2, "Count of requests");
}, "Reports are not batched for same url in different document.");
</script>
</body>
</html>