tor-browser

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

interim-response-times.h2.html (2769B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8" />
      5 <meta name="timeout" content="long">
      6 <title>Resource Timing: PerformanceResourceTiming interim resource times</title>
      7 <link rel="author" title="Google" href="http://www.google.com/" />
      8 <script src="/common/utils.js"></script>
      9 <script src="/common/get-host-info.sub.js"></script>
     10 <script src="/resources/testharness.js"></script>
     11 <script src="/resources/testharnessreport.js"></script>
     12 <script>
     13  const {REMOTE_HOST} = get_host_info();
     14  function interim_response_time_test({origin, with100, with103}) {
     15    promise_test(async t => {
     16      const delay = 500;
     17      const url = new URL('/resource-timing/resources/header-delay.h2.py',
     18      origin == "same-origin" ?
     19          location.href :
     20          `${location.protocol}//${REMOTE_HOST}:${location.port}`);
     21      url.searchParams.set("delay", delay);
     22      if (origin === "cross-origin-with-TAO")
     23        url.searchParams.set("tao", "*");
     24      if (with100)
     25        url.searchParams.set("with100", "true");
     26      if (with103)
     27        url.searchParams.set("with103", "true");
     28      const response = await fetch(url.toString(), {mode: "cors"});
     29      assert_equals(response.status, 200)
     30      await response.text();
     31      const [entry] = performance.getEntriesByName(url.toString());
     32      if (origin === "cross-origin") {
     33        assert_equals(entry.firstInterimResponseStart, 0);
     34        return;
     35      }
     36      let total_delay = entry.requestStart;
     37      if (with100) {
     38        total_delay += delay;
     39        assert_greater_than(entry.firstInterimResponseStart,
     40        total_delay,
     41                            "firstInterimResponseStart > 100 response");
     42      }
     43 
     44      if (with103) {
     45        total_delay += delay;
     46        if (with100) {
     47          assert_less_than_equal(entry.firstInterimResponseStart,
     48          total_delay,  "firstInterimResponseStart > 100 response");
     49        } else {
     50          assert_greater_than(entry.firstInterimResponseStart,
     51          delay, "firstInterimResponseStart > 100 response");
     52        }
     53      }
     54 
     55      total_delay += delay;
     56      if (!with100 && !with103)
     57        assert_equals(entry.firstInterimResponseStart, 0);
     58 
     59      assert_greater_than(entry.finalResponseHeadersStart, total_delay, "responseStart");
     60      assert_equals(entry.responseStart, entry.firstInterimResponseStart || entry.finalResponseHeadersStart);
     61    }, `Fetch from ${origin} ${with103 ? "with" : "without"} early hints, ${
     62        with100 ? "with" : "without"} 100 response`);
     63  }
     64 
     65  for (const with103 of [true, false]) {
     66    for (const with100 of [true, false]) {
     67      for (origin of ['same-origin', 'cross-origin', 'cross-origin-with-TAO']) {
     68        interim_response_time_test({with100, with103, origin});
     69      }
     70    }
     71  }
     72 </script>
     73 </body>
     74 </html>