tor-browser

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

report-only-in-meta.sub.html (1880B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <title>Report-only policy not allowed in meta tag</title>
      5    <meta name="timeout" content="long">
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8    <!-- CSP headers
      9         Content-Security-Policy: script-src 'unsafe-inline' 'self'
     10         -->
     11    <!-- since we try to set the report-uri in the meta tag, we have to set the cookie with the reportID in here instead of in the headers file -->
     12    <meta http-equiv="Content-Security-Policy-Report-Only" content="img-src 'none'; report-uri /reporting/resources/report.py?op=put&reportID={{$id:uuid()}}">
     13 </head>
     14 <body>
     15  <script>
     16    var test = async_test("Image should load");
     17 
     18    <!-- Set cookie for checking if the report exists
     19      -->
     20    fetch(
     21      "support/set-cookie.py?name=report-only-in-meta&value={{$id}}&path=" + encodeURIComponent("/content-security-policy/reporting/"),
     22      {mode: 'no-cors', credentials: 'include'})
     23    .then(() => {
     24      const img = new Image();
     25      img.onload = test.step_func_done();
     26      img.onerror = test.unreached_func("Should have loaded the image");
     27 
     28      img.src = "../support/pass.png";
     29      document.body.appendChild(img);
     30 
     31      <!-- this needs to be done after setting the cookie so we do it here -->
     32      const script = document.createElement('script');
     33      script.async = true;
     34      script.defer = true;
     35      script.src = '../support/checkReport.sub.js?reportExists=false'
     36      document.body.appendChild(script);
     37 
     38      // Immediately declare a test so that the harness does not infer
     39      // completion if the image loads before the script.
     40      var checkReportTest = async_test("checkReport tests loaded");
     41      script.onload = checkReportTest.step_func_done();
     42      script.onerror = checkReportTest.unreached_func();
     43    });
     44  </script>
     45 </body>
     46 </html>