cross-origin-report-no-credentials.https.sub.html (1594B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test that reports are sent without credentials to cross-origin endpoints</title> 5 <script src='/resources/testharness.js'></script> 6 <script src='/resources/testharnessreport.js'></script> 7 <script src='resources/report-helper.js'></script> 8 </head> 9 <body> 10 <script> 11 const base_url = `${location.protocol}//${location.host}`; 12 const endpoint = `${base_url}/reporting/resources/report.py`; 13 const id = 'fe5ca189-269a-4e74-a4dd-d7a3b33139d5'; 14 15 promise_test(async t => { 16 // Set credentials, and set up test to clear them afterwards. 17 await fetch('/cookies/resources/set-cookie.py?name=report&path=%2F', {mode: 'no-cors', credentials: 'include', cache: 'no-store'}); 18 t.add_cleanup(() => fetch("/cookies/resources/set.py?report=; path=%2F; expires=Thu, 01 Jan 1970 00:00:01 GMT")); 19 20 // Trigger a CSP error. 21 await new Promise(resolve => { 22 const img = document.createElement('img'); 23 img.src = "/reporting/resources/fail.png"; 24 img.addEventListener('error', resolve); 25 document.body.appendChild(img); 26 }); 27 28 // Wait for report to be received. 29 const reports = await pollReports(endpoint, id); 30 checkReportExists(reports, 'csp-violation', location.href); 31 32 // Validate that credentials were not sent to cross-origin endpoint. 33 const cookies = await pollCookies(endpoint, id); 34 assert_equals(Object.keys(cookies).length, 0, "Credentials were absent from report"); 35 }, "Reporting endpoints did not receive credentials."); 36 </script> 37 </body> 38 </html>