summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/object-not-found-after-cross-origin-redirect.html
blob: 6990c6c06082e5d62ba3aa576eccd42d13246d2a (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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>This test validates the values in resource timing for cross-origin
redirects.</title>
<meta name="timeout" content="long">
<link rel="author" title="Noam Rosenthal" href="noam@webkit.org">
<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/resource-loaders.js"></script>
<script src="resources/entry-invariants.js"></script>
</head>
<body>
<script>
const {REMOTE_ORIGIN} = get_host_info();
const delay = 1;
const not_found_page = encodeURIComponent("/resource-timing/resources/status-code.py?status=404");
const load_null_object = async path => {
  return load.object(path, null);
}
const destUrl = `/common/slow-redirect.py?delay=${delay}&location=${REMOTE_ORIGIN}${not_found_page}`;

const timeBefore = performance.now();
(async () => {
  // Wait 10 ms, to ensure the difference between startTime and timeBefore is
  // larger than 1 ms, to avoid flakiness in browsers that clamp timestamps to
  // 1 ms.
  await new Promise(r => step_timeout(r, 10));
  attribute_test(load_null_object, destUrl, entry => {
      assert_equals(entry.startTime, entry.fetchStart, 'startTime and fetchStart should be equal');
      assert_greater_than(entry.startTime, timeBefore, 'startTime and fetchStart should be greater than the time before fetching');
      // See https://github.com/w3c/resource-timing/issues/264
      assert_less_than(Math.round(entry.startTime - timeBefore), delay * 1000, 'startTime should not expose redirect delays');
  }, "Verify that cross-origin object resources don't implicitly expose their redirect timings")
})();

</script>
</body>
</html>