document-reporting-not-batch-different-document.https.html (1578B)
1 <!DOCTYPE HTML> 2 <html> 3 4 <head> 5 <title>Test that reports are sent to multiple named endpoints</title> 6 <script src='/resources/testharness.js'></script> 7 <script src='/resources/testharnessreport.js'></script> 8 <script src='resources/report-helper.js'></script> 9 </head> 10 11 <body> 12 <iframe name="report1"></iframe> 13 <iframe name="report2"></iframe> 14 <script> 15 const base_url = `${location.protocol}//${location.host}`; 16 const endpoint = `${base_url}/reporting/resources/report.py`; 17 const report_id = '204d2fb2-018b-4e35-964c-5e298e89d4e2'; 18 promise_test(async t => { 19 const w = window.open(`resources/generate-report.https.sub.html?pipe=header(Reporting-Endpoints,default="/reporting/resources/report.py?reportID=${report_id}")`, "report1"); 20 const w2 = window.open(`resources/generate-csp-report.https.sub.html?pipe=header(Reporting-Endpoints,default="/reporting/resources/report.py?reportID=${report_id}")`, "report2"); 21 await wait(3000); 22 // Verify that each iframe generated and sent one report. 23 const reports = await pollReports(endpoint, report_id); 24 assert_equals(reports.length, 2, "Number of reports"); 25 checkReportExists(reports, 'deprecation', w.location.href); 26 checkReportExists(reports, 'csp-violation', w2.location.href); 27 const request_count = await pollNumResults(endpoint, report_id); 28 // Verify that requests are sent separately. 29 assert_equals(request_count, 2, "Count of requests"); 30 }, "Reports are not batched for same url in different document."); 31 </script> 32 33 </body> 34 35 </html>