| 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 var presentationModel = InspectorTest.timelinePresentationModel(); | |
| 24 | |
| 25 InspectorTest.invokeAsyncWithTimeline("performActions", finish); | |
| 26 | |
| 27 function finish() | |
| 28 { | |
| 29 var lastRecordStartTime; | |
| 30 function format(record) | |
| 31 { | |
| 32 if (record.type() === WebInspector.TimelineModel.RecordType.Resource
SendRequest) | |
| 33 printSend(record); | |
| 34 else if (record.type() === WebInspector.TimelineModel.RecordType.Res
ourceReceiveResponse) | |
| 35 printReceive(record); | |
| 36 else if (record.type() === WebInspector.TimelineModel.RecordType.Res
ourceFinish) | |
| 37 printFinish(record); | |
| 38 | |
| 39 var presentationRecord = presentationModel.toPresentationRecord(reco
rd); | |
| 40 if (presentationRecord && record.thread() === WebInspector.TimelineM
odel.MainThreadName) { | |
| 41 var parentIsRoot = presentationRecord.presentationParent() && !p
resentationRecord.presentationParent().presentationParent(); | |
| 42 if (parentIsRoot) { | |
| 43 if (lastRecordStartTime) | |
| 44 InspectorTest.assertGreaterOrEqual(record.startTime(), l
astRecordStartTime, "Top level records order violation"); | |
| 45 lastRecordStartTime = record.startTime(); | |
| 46 } | |
| 47 } | |
| 48 } | |
| 49 model.forAllRecords(format); | |
| 50 InspectorTest.completeTest(); | |
| 51 } | |
| 52 | |
| 53 function printRecord(record) | |
| 54 { | |
| 55 InspectorTest.addResult(""); | |
| 56 InspectorTest.printTimelineRecordProperties(record); | |
| 57 } | |
| 58 | |
| 59 function printSend(record) | |
| 60 { | |
| 61 printRecord(record); | |
| 62 requestId = record.data().requestId; | |
| 63 if (record.data().url === undefined) | |
| 64 InspectorTest.addResult("* No 'url' property in record"); | |
| 65 else if (record.data().url.indexOf(scriptUrl) === -1) | |
| 66 InspectorTest.addResult("* Didn't find URL: " + scriptUrl); | |
| 67 } | |
| 68 | |
| 69 function printReceive(record) | |
| 70 { | |
| 71 printRecord(record); | |
| 72 if (requestId !== record.data().requestId) | |
| 73 InspectorTest.addResult("Didn't find matching requestId: " + request
Id); | |
| 74 if (record.data().statusCode !== 0) | |
| 75 InspectorTest.addResult("Response received status: " + record.data()
.statusCode); | |
| 76 } | |
| 77 | |
| 78 function printFinish(record) | |
| 79 { | |
| 80 printRecord(record); | |
| 81 if (requestId !== record.data().requestId) | |
| 82 InspectorTest.addResult("Didn't find matching requestId: " + request
Id); | |
| 83 if (record.data().didFail) | |
| 84 InspectorTest.addResult("Request failed."); | |
| 85 } | |
| 86 } | |
| 87 | |
| 88 </script> | |
| 89 </head> | |
| 90 | |
| 91 <body onload="runTest()"> | |
| 92 <p> | |
| 93 Tests the Timeline API instrumentation of a network resource load | |
| 94 </p> | |
| 95 </body> | |
| 96 </html> | |
| OLD | NEW |