summaryrefslogtreecommitdiffstats
path: root/dom/performance/tests/test_performance_server_timing_plain_http.html
blob: 7dcb8bd38d316f3bb0471d75a551dd76931e033e (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
<!--
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Plain HTTP Test for PerformanceServerTiming</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
function makeXHR(aUrl) {
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.open("get", aUrl, true);
  xmlhttp.send();
}

promise_test(t => {
  var promise = new Promise(resolve => {
    performance.clearResourceTimings();

    var observer = new PerformanceObserver(list => resolve(list));
    observer.observe({entryTypes: ['resource']});
    t.add_cleanup(() => observer.disconnect());
  });

  makeXHR("serverTiming.sjs");

  return promise.then(list => {
    assert_equals(list.getEntries().length, 1);
    assert_equals(list.getEntries()[0].serverTiming, undefined);
    assert_equals(list.getEntries()[0].toJSON().serverTiming, undefined,
		  "toJSON should not pick up properties that aren't on the object");
  });
}, "server-timing test");

</script>
</body>