summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/connection-reuse.html
blob: a1bc927cfd3f2bdd960c4f686951b826f75e8fc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing connection reuse</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#sec-performanceresourcetiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/entry-invariants.js"></script>
<script src="resources/connection-reuse-test.js"></script>
<script>
  const {HTTPS_ORIGIN} = get_host_info();

  // Fetches the given subresource a couple times with the same connection.
  const http_path = "resources/fake_responses.py";
  connection_reuse_test(http_path,
    {
      'on_200': invariants.assert_tao_pass_no_redirect_http,
      'on_304': invariants.assert_tao_pass_304_not_modified_http,
    }, "Reuse HTTP connection");

  // Like above, but the subresource is fetched over HTTPS while this page is
  // fetched over HTTP.
  const https_url = `${HTTPS_ORIGIN}/resource-timing/${http_path}`;
  connection_reuse_test(https_url,
    {
      'on_200': invariants.assert_tao_pass_no_redirect_https,
      'on_304': invariants.assert_tao_pass_304_not_modified_https,
    }, "Reuse HTTPS connection from HTTP page");

  // Like the above mixed-content test but the final resource is behind an HTTP
  // redirect response.
  const redirect_path = (() => {
    // The resource behind the redirect is the same fake_responses.py handler
    // on the HTTPS origin. Pass it through encodeURIComponent so that it can
    // be passed through a query-parameter.
    const redirect_url = encodeURIComponent(https_url)
    // The request is made to the HTTPS origin with a query parameter that will
    // cause a 302 response.
    return `${https_url}?redirect=${redirect_url}`;
  })();
  connection_reuse_test(redirect_path,
    {
      'on_200': invariants.assert_tao_enabled_cross_origin_redirected_resource,
      'on_304': invariants.assert_tao_enabled_cross_origin_redirected_resource,
    }, "Reuse HTTPS connection with redirects from an HTTP page");
</script>
</head>
<body>
<h1>Description</h1>
<p>See <a href="resources/connection-reuse-test.js">the included test
  script</a></p>
</body>
</html>