3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script>
8 // Wait 100 ms, then serve for 200ms file containing 300ms loop.
9 var script = document.createElement("script");
10 script.setAttribute("src", "resources/resource.php?type=js&wait=100&send=200&jsdelay=300&jscontent=resourceLoaded()");
11 document.head.appendChild(script);
13 // Wait 100 ms, then serve for 100ms and call console.log in content.
14 script = document.createElement("script");
15 script.setAttribute("src", "resources/resource.php?type=js&wait=100&send=100&jscontent=resourceLoaded()");
16 document.head.appendChild(script);
19 var loadedResourceCount = 0;
20 function resourceLoaded()
22 if (++loadedResourceCount === 2)
28 InspectorTest.addConsoleSniffer(step2);
29 InspectorTest.evaluateInPage("loadScripts()");
33 // inspector-test.js appears in network panel occasionally in Safari on
34 // Mac, so checking two last requests.
35 var timerThreshold = 15; // Windows timer accuracy.
36 var requests = InspectorTest.networkRequests();
37 var requestsCount = requests.length;
38 var request1 = requests[requestsCount - 2];
39 InspectorTest.addResult(request1.url);
40 InspectorTest.assertGreaterOrEqual(request1.latency * 1000, 100 - timerThreshold, "Latency of the first resource");
41 InspectorTest.assertGreaterOrEqual(request1.duration * 1000, 300 - timerThreshold, "Duration of the first resource");
43 var request2 = requests[requestsCount - 1];
44 InspectorTest.addResult(request2.url);
45 InspectorTest.assertGreaterOrEqual(request2.latency * 1000, 100 - timerThreshold, "Latency of the second resource");
46 InspectorTest.assertGreaterOrEqual(request2.duration * 1000, 100 - timerThreshold, "Duration of the second resource");
47 InspectorTest.completeTest();
52 <body onload="runTest()">
53 <p>Tests network panel timing.</p>