tor-browser

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

document-reporting-override-endpoint.https.sub.html (1708B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 
      4 <head>
      5  <title>Test that Reporting-Endpoints header endpoint with same name override previous value</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 first_group1_id = 'b523d7f5-28f0-4be6-9460-e163ee9b4ab8';
     32    const second_group1_id = '03e4474d-768c-42f2-8e17-39aa95b309e3';
     33    promise_test(async t => {
     34      await wait(3000);
     35      // Verify that no reports are sent to old header endpoint.
     36      let reports = await pollReports(endpoint, first_group1_id);
     37      assert_equals(reports.length, 0);
     38      // Verify that reports are sent to the new header endpoint.
     39      reports = await pollReports(endpoint, second_group1_id);
     40      checkReportExists(reports, 'document-policy-violation', location.href);
     41    }, "Only the second reporting endpoint received reports.");
     42  </script>
     43 
     44 </body>
     45 
     46 </html>