OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | |
4 <script src="../../http/tests/inspector/timeline-test.js"></script> | |
5 <script> | |
6 | |
7 var scriptUrl = "timeline-network-resource.js"; | |
8 | |
9 function performActions(callback) | |
10 { | |
11 window.timelineNetworkResourceEvaluated = callback; | |
12 var script = document.createElement("script"); | |
13 script.src = scriptUrl; | |
14 document.body.appendChild(script); | |
15 } | |
16 | |
17 function test() | |
18 { | |
19 var requestId; | |
20 var scriptUrl = "timeline-network-resource.js"; | |
21 | |
22 var model = WebInspector.panels.timeline._model; | |
23 | |
24 InspectorTest.invokeAsyncWithTimeline("performActions", finish); | |
25 | |
26 function finish() | |
27 { | |
28 var lastRecordStartTime; | |
29 function format(record) | |
30 { | |
31 if (record.type() === WebInspector.TimelineModel.RecordType.Resource
SendRequest) | |
32 printSend(record); | |
33 else if (record.type() === WebInspector.TimelineModel.RecordType.Res
ourceReceiveResponse) | |
34 printReceive(record); | |
35 else if (record.type() === WebInspector.TimelineModel.RecordType.Res
ourceFinish) | |
36 printFinish(record); | |
37 } | |
38 model.forAllRecords(format); | |
39 InspectorTest.completeTest(); | |
40 } | |
41 | |
42 function printRecord(record) | |
43 { | |
44 InspectorTest.addResult(""); | |
45 InspectorTest.printTimelineRecordProperties(record); | |
46 InspectorTest.addResult("Text details for " + record.type() + ": " + Web
Inspector.TimelineUIUtils.buildDetailsTextForTraceEvent(record.traceEvent())); | |
47 } | |
48 | |
49 function printSend(record) | |
50 { | |
51 printRecord(record); | |
52 var data = record.traceEvent().args["data"]; | |
53 requestId = data.requestId; | |
54 if (data.url === undefined) | |
55 InspectorTest.addResult("* No 'url' property in record"); | |
56 else if (data.url.indexOf(scriptUrl) === -1) | |
57 InspectorTest.addResult("* Didn't find URL: " + scriptUrl); | |
58 } | |
59 | |
60 function printReceive(record) | |
61 { | |
62 printRecord(record); | |
63 var data = record.traceEvent().args["data"]; | |
64 if (requestId !== data.requestId) | |
65 InspectorTest.addResult("Didn't find matching requestId: " + request
Id); | |
66 if (data.statusCode !== 0) | |
67 InspectorTest.addResult("Response received status: " + data.statusCo
de); | |
68 } | |
69 | |
70 function printFinish(record) | |
71 { | |
72 printRecord(record); | |
73 var data = record.traceEvent().args["data"]; | |
74 if (requestId !== data.requestId) | |
75 InspectorTest.addResult("Didn't find matching requestId: " + request
Id); | |
76 if (data.didFail) | |
77 InspectorTest.addResult("Request failed."); | |
78 } | |
79 } | |
80 | |
81 </script> | |
82 </head> | |
83 | |
84 <body onload="runTest()"> | |
85 <p> | |
86 Tests the Timeline API instrumentation of a network resource load | |
87 </p> | |
88 </body> | |
89 </html> | |
OLD | NEW |