tor-browser

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

sends-report-on-cache-validation.https.html (1398B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>
      5    Test that NEL reports are sent for cache validation requests
      6  </title>
      7  <script src='/resources/testharness.js'></script>
      8  <script src='/resources/testharnessreport.js'></script>
      9  <script src='./support/nel.sub.js'></script>
     10 </head>
     11 <body>
     12  <script>
     13    nel_test(async t => {
     14      // Fetch a resource that can be cached, but whose response requires
     15      // validation.  Do this *before* fetching the NEL policy for this origin,
     16      // to ensure that we don't generate any report about this request.
     17      await fetchValidatedCachedResource();
     18      // Fetch the NEL policy for this origin.
     19      await fetchResourceWithBasicPolicy();
     20      // Fetch the now-cached resource again.  Because the response requires
     21      // validation, this will result in a network request.
     22      await fetchValidatedCachedResource();
     23      // We should receive a report about the cache validation request.
     24      assert_true(await reportExists({
     25        url: getURLForValidatedCachedResource(),
     26        user_agent: navigator.userAgent,
     27        type: "network-error",
     28        body: {
     29          method: "GET",
     30          sampling_fraction: 1.0,
     31          status_code: 304,
     32          phase: "application",
     33          type: "ok",
     34        },
     35        metadata: {
     36          content_type: "application/reports+json",
     37        },
     38      }));
     39    });
     40  </script>
     41 </body>
     42 </html>