blob: 65eb2c2d828fe6bf1c26cb2810335282ee9ed557 [file] [log] [blame]
<html>
<head>
<script src="../inspector-test.js"></script>
<script>
function loadScripts()
{
// Wait 100 ms, then serve for 200ms file containing 300ms loop.
var script = document.createElement("script");
script.setAttribute("src", "resources/resource.php?type=js&wait=100&send=200&jsdelay=300&jscontent=resourceLoaded()");
document.head.appendChild(script);
// Wait 100 ms, then serve for 100ms and call console.log in content.
script = document.createElement("script");
script.setAttribute("src", "resources/resource.php?type=js&wait=100&send=100&jscontent=resourceLoaded()");
document.head.appendChild(script);
}
var loadedResourceCount = 0;
function resourceLoaded()
{
if (++loadedResourceCount === 2)
console.log("Done.");
}
function test()
{
InspectorTest.addConsoleSniffer(step2);
InspectorTest.evaluateInPage("loadScripts()");
function step2()
{
// inspector-test.js appears in network panel occasionally in Safari on
// Mac, so checking two last requests.
var requests = WebInspector.networkLog.requests;
var requestsCount = requests.length;
var request1 = requests[requestsCount - 2];
InspectorTest.addResult(request1.url);
InspectorTest.assertGreaterOrEqual(request1.latency * 1000, 100, "Latency of the first resource");
InspectorTest.assertGreaterOrEqual(request1.duration * 1000, 300, "Duration of the first resource");
var request2 = requests[requestsCount - 1];
InspectorTest.addResult(request2.url);
InspectorTest.assertGreaterOrEqual(request2.latency * 1000, 100, "Latency of the second resource");
InspectorTest.assertGreaterOrEqual(request2.duration * 1000, 100, "Duration of the second resource");
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>Tests network panel timing.</p>
</body>
</html>