summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-timing/test-performance-attributes.sub.html
blob: 50d027e80ce5ccb110399ea6c8d9c7614fc320fa (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
<!DOCTYPE HTML>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Use https to ensure secureConnectionStart is nontrivial, if it is supported. -->
<iframe src="https://{{host}}:{{ports[https][0]}}/navigation-timing/resources/performance-attribute-sender.html"></iframe>
<body>
<script>
async_test(function(t) {
  window.addEventListener('message', t.step_func_done(function(event) {
    const connectStart = event.data[0];
    const navigationStart = event.data[1];
    const secureConnectionStart = event.data[2];
    const connectEnd = event.data[3];
    assert_greater_than_equal(connectStart, navigationStart,
      'performance.timing.connectStart >= performance.timing.navigationStart');
    // secureConnectionStart is an optional attribute.
    if (secureConnectionStart == undefined) {
      return;
    }
    assert_greater_than_equal(secureConnectionStart, connectStart,
      'performance.timing.secureConnectionStart >= performance.timing.connectStart');
    assert_greater_than_equal(connectEnd, secureConnectionStart,
      'performance.timing.connectEnd >= performance.timing.secureConnectionStart');
  }));
}, 'Check that performance.timing has reasonable values for secureConnectionStart and other attributes');
</script>
</body>
</html>