blob: 77094f4b843a43fb30aeca48c505337b4322ca81 [file] [log] [blame]
Nicolas Pena3b82bae2018-01-03 15:49:131<!doctype html>
2<html>
3<head>
4<script src="/resources/testharness.js"></script>
5<script src="/resources/testharnessreport.js"></script>
6</head>
7<body>
8<script>
9 const img_url = "resources/blue.png";
10 const img = document.createElement("img");
11 img.src = img_url;
12 window.onload = function() {
13 test(() => {
14 const entries = performance.getEntriesByType('resource');
15 assert_greater_than_equal(entries.length, 1);
16 const entry = entries[0];
17 assert_equals(typeof(entry.toJSON), 'function');
18 const json = entry.toJSON();
19 assert_equals(typeof(json), 'object');
20
21 const performanceResourceTimingKeys = [
22 'name',
23 'entryType',
24 'startTime',
25 'duration',
26 'initiatorType',
27 'nextHopProtocol',
28 'workerStart',
29 'redirectStart',
30 'fetchStart',
31 'domainLookupStart',
32 'domainLookupEnd',
33 'connectStart',
34 'connectEnd',
35 'secureConnectionStart',
36 'requestStart',
37 'responseStart',
38 'responseEnd',
39 'transferSize',
40 'encodedBodySize',
41 'decodedBodySize'
42 ];
43 for (const key of performanceResourceTimingKeys) {
44 assert_equals(json[key], entry[key],
45 `entry.toJSON().${key} should match entry.${key}`);
46 }
47 }, 'Test toJSON() in PerformanceResourceTiming');
48 };
49</script>
50</body>
51</html>