tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

report-same-origin-with-cookies.html (1745B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <script src="/resources/testharness.js"></script>
      5    <script src="/resources/testharnessreport.js"></script>
      6    <title>Cookies are sent on same origin violation reports</title>
      7    <!-- CSP headers
      8         Content-Security-Policy: script-src 'unsafe-inline' 'self'; img-src 'none'; report-uri /reporting/resources/report.py?op=put&reportID={{$id}}
      9         -->
     10 </head>
     11 <body>
     12 <script>
     13  var test = async_test("Image should not load");
     14  fetch(
     15    "/cookies/resources/set-cookie.py?name=cspViolationReportCookie2&path=" + encodeURIComponent("/"),
     16    {mode: 'no-cors', credentials: 'include'})
     17  .then(() => {
     18    // Loading `img` will generate a CSP violation report.
     19    // As this test is for covering the behavior of the deprecated "report-uri" directive [1], the
     20    // underlying report is backed by a browser-initiated fetch "keepalive" request [2]. Per
     21    // keepalive spec [3], such request may outlive this entire document itself. Hence, the cookie
     22    // this test wants to test, i.e. "cspViolationReportCookie2", must NOT be cleared before the
     23    // browser entirely sending out the report request.
     24    // [1]: https://www.w3.org/TR/CSP3/#report-uri
     25    // [2]: https://www.w3.org/TR/CSP3/#report-violation
     26    // [3]: https://fetch.spec.whatwg.org/#request-keepalive-flag
     27    const img = new Image();
     28    img.onerror = test.step_func_done();
     29    img.onload = test.unreached_func("Should not have loaded the image");
     30 
     31    img.src = "../support/fail.png";
     32    document.body.appendChild(img);
     33  });
     34 </script>
     35 <script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=img-src%20%27none%27&cookiePresent=cspViolationReportCookie2'></script>
     36 
     37 </body>
     38 </html>