tor-browser

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

sxg-reporting-navigation-failed-zero-success-fraction.tentative.html (2478B)


      1 <!DOCTYPE html>
      2 <title>SXG reporting test of sxg.failed for navigation (zero success fraction)</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/get-host-info.sub.js"></script>
      6 <script src="/network-error-logging/support/nel.sub.js"></script>
      7 <script src="../resources/sxg-util.js"></script>
      8 <body>
      9 <script>
     10 const alt_origin = get_host_info().HTTPS_NOTSAMESITE_ORIGIN;
     11 const test_origin = get_host_info().HTTPS_ORIGIN;
     12 
     13 nel_iframe_test(async t => {
     14  await loadResourceWithZeroSuccessFractionPolicyInIframe();
     15  const sxg_url =
     16      alt_origin + '/signed-exchange/resources/sxg/sxg-cert-not-found.sxg?navigation';
     17  const cert_url = test_origin + '/signed-exchange/resources/not_found_certfile.cbor';
     18  const message = await openSXGInIframeAndWaitForMessage(t, sxg_url);
     19  assert_equals(message.location,
     20                innerURLOrigin() + '/signed-exchange/resources/inner-url.html');
     21  assert_true(message.is_fallback);
     22  assert_true(await reportExists(
     23    {
     24      url: sxg_url,
     25      user_agent: navigator.userAgent,
     26      type: "network-error",
     27      body: {
     28        phase: "sxg",
     29        // The origin of this SXG's certURL is different from the reporting
     30        // origin. So the report must be downgraded.
     31        type: "sxg.failed",
     32        elapsed_time: 0,
     33        status_code: 200,
     34        referrer: location.origin + '/',
     35        sxg: {
     36          outer_url: sxg_url,
     37          inner_url:
     38              innerURLOrigin() + '/signed-exchange/resources/inner-url.html',
     39          cert_url: cert_url
     40        }
     41      },
     42      metadata: {
     43        content_type: "application/reports+json",
     44      },
     45    }
     46  ), 'SXG error reporting must be downgraded when the cert URL is different ' +
     47     'from the reporting origin');
     48  assert_false(await reportExists(
     49    {
     50      url: sxg_url,
     51      user_agent: navigator.userAgent,
     52      type: "network-error",
     53      body: {
     54        phase: "application",
     55        type: "ok",
     56        status_code: 200,
     57        referrer: location.origin + '/',
     58      },
     59      metadata: {
     60        content_type: "application/reports+json",
     61      },
     62    }
     63  ), 'Succeeded normal NEL report should not be sent when success fraction ' +
     64     'is zero.');
     65 }, 'SXG error report must be downgraded when the cert URL is different from ' +
     66   'the reporting origin. And succeeded normal NEL report should not be sent ' +
     67   ' when success fraction is zero.');
     68 </script>
     69 </body>