Rubber-stamped by Brady Eidson.
[webbrowser.git] / LayoutTests / inspector / timeline-network-resource.html
blobae46d2e744c2f860952309d1ce341b66a0f7dac1
1 <html>
2 <head>
3 <script src="inspector-test.js"></script>
4 <script src="timeline-test.js"></script>
5 <script>
7 var scriptUrl = "timeline-network-resource.js";
9 function runAfterScriptIsEvaluated(continuation)
11 function step()
13 if (!window.scriptEvaluated)
14 setTimeout(step, 100);
15 else
16 continuation();
18 setTimeout(step, 100);
21 function printRecord(record)
23 output("");
24 printTimelineRecordProperties(record);
27 function printSend(record)
29 printRecord(record);
30 window.resourceId = record.data.identifier;
31 if (record.data.url === undefined)
32 output("* No 'url' property in record");
33 else if (record.data.url.indexOf(scriptUrl) === -1)
34 output("* Didn't find URL: " + scriptUrl);
37 function printReceive(record)
39 printRecord(record);
40 if (window.resourceId !== record.data.identifier)
41 output("Didn't find matching resourceId: " + window.resourceId);
42 if (record.data.statusCode !== 0)
43 output("Response received status: " + record.data.statusCode);
46 function printFinish(record)
48 printRecord(record);
49 if (window.resourceId !== record.data.identifier)
50 output("Didn't find matching resourceId: " + window.resourceId);
51 if (record.data.didFail)
52 output("Request failed.");
55 function doit()
57 if (window.layoutTestController)
58 layoutTestController.setTimelineProfilingEnabled(true);
60 var script = document.createElement("script");
61 script.src = scriptUrl;
62 document.body.appendChild(script);
63 runAfterScriptIsEvaluated(function() {
64 printTimelineRecords(null, null, function(record) {
65 if (record.type === timelineAgentRecordType["ResourceSendRequest"])
66 printSend(record);
68 else if (record.type === timelineAgentRecordType["ResourceReceiveResponse"])
69 printReceive(record);
70 else if (record.type === timelineAgentRecordType["ResourceFinish"])
71 printFinish(record);
72 });
73 });
76 </script>
77 </head>
79 <body onload="onload()">
80 <p>
81 Tests the Timeline API instrumentation of a network resource load
82 </p>
83 </body>
84 </html>