tor-browser

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

sxg-navigation-timing.tentative.html (1213B)


      1 <!DOCTYPE html>
      2 <title>Navigation timing of SignedHTTPExchange</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="./resources/sxg-util.js"></script>
      7 <body>
      8 <script>
      9 promise_test(async (t) => {
     10  const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg/sxg-navigation-timing.sxg';
     11  const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
     12  assert_false(message.is_fallback);
     13 
     14  let timing = JSON.parse(message.timing);
     15  let originalContent = await fetch('resources/sxg-navigation-timing.html').then(resp => resp.arrayBuffer());
     16 
     17  assert_equals(timing.decodedBodySize, originalContent.byteLength);
     18  assert_equals(timing.encodedBodySize, computeMiceLength(originalContent.byteLength, 100));
     19  // TODO(https://crbug.com/928589): Test other fields too.
     20 }, 'Navigation timing of SignedHTTPExchange');
     21 
     22 // Returns content length after MI encode.
     23 function computeMiceLength(len, recordSize) {
     24  const recordSizeLen = 8;
     25  const sha256DigestLength = 32;
     26  return recordSizeLen + len + Math.floor(len / recordSize) * sha256DigestLength;
     27 }
     28 
     29 </script>
     30 </body>