tor-browser

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

document-reporting-bypass-report-to.https.sub.html (1716B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 
      4 <head>
      5  <title>Test that reports ignore Report-To header when Reporting-Endpoints is configured</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  <script>
     13    promise_test(async t => {
     14      return new Promise(resolve => {
     15        new ReportingObserver((reports, observer) => resolve(reports),
     16          { types: ['document-policy-violation'] }).observe();
     17      }).then((reports) => {
     18        assert_equals(reports[0].type, 'document-policy-violation');
     19      })
     20    }, "document policy violation observed");
     21  </script>
     22  <script>
     23    // Attempt a synchronous XHR - this should succeed but cause a report to be sent.
     24    const xhr = new XMLHttpRequest();
     25    xhr.open("GET", document.location.href, false);
     26    xhr.send();
     27  </script>
     28  <script>
     29    const base_url = `${location.protocol}//${location.host}`;
     30    const endpoint = `${base_url}/reporting/resources/report.py`;
     31      const report_to_id = 'caddb022-90ea-48e8-a675-4cebaf7e8388';
     32    const reporting_endpoints_id = '6c2131d0-1e9b-4ee8-a196-952f2ae4ae97';
     33    promise_test(async t => {
     34      await wait(3000);
     35      // Verify no reports sent to Report-To endpoint
     36      let reports = await pollReports(endpoint, report_to_id);
     37      assert_equals(reports.length, 0);
     38      // Verify report is received on Reporting-Endpoints endpoint
     39      reports = await pollReports(endpoint, reporting_endpoints_id);
     40      checkReportExists(reports, 'document-policy-violation', location.href);
     41    }, "Only the Reporting-Endpoints configured endpoint received reports.");
     42  </script>
     43 
     44 </body>
     45 
     46 </html>