3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/timeline-test.js"></script>
7 var scriptUrl
= "timeline-network-resource.js";
9 function performActions(callback
)
11 window
.timelineNetworkResourceEvaluated
= callback
;
12 var script
= document
.createElement("script");
13 script
.src
= scriptUrl
;
14 document
.body
.appendChild(script
);
20 var scriptUrl
= "timeline-network-resource.js";
22 var model
= WebInspector
.panels
.timeline
._model
;
23 var presentationModel
= InspectorTest
.timelinePresentationModel();
25 InspectorTest
.invokeAsyncWithTimeline("performActions", finish
);
29 var lastRecordStartTime
;
30 function format(record
)
32 if (record
.type() === WebInspector
.TimelineModel
.RecordType
.ResourceSendRequest
)
34 else if (record
.type() === WebInspector
.TimelineModel
.RecordType
.ResourceReceiveResponse
)
36 else if (record
.type() === WebInspector
.TimelineModel
.RecordType
.ResourceFinish
)
39 var presentationRecord
= presentationModel
.toPresentationRecord(record
);
40 if (presentationRecord
&& record
.thread() === WebInspector
.TimelineModel
.MainThreadName
) {
41 var parentIsRoot
= presentationRecord
.presentationParent() && !presentationRecord
.presentationParent().presentationParent();
43 if (lastRecordStartTime
)
44 InspectorTest
.assertGreaterOrEqual(record
.startTime(), lastRecordStartTime
, "Top level records order violation");
45 lastRecordStartTime
= record
.startTime();
49 model
.forAllRecords(format
);
50 InspectorTest
.completeTest();
53 function printRecord(record
)
55 InspectorTest
.addResult("");
56 InspectorTest
.printTimelineRecordProperties(record
);
59 function printSend(record
)
62 var data
= record
.traceEvent().args
["data"];
63 requestId
= data
.requestId
;
64 if (data
.url
=== undefined)
65 InspectorTest
.addResult("* No 'url' property in record");
66 else if (data
.url
.indexOf(scriptUrl
) === -1)
67 InspectorTest
.addResult("* Didn't find URL: " + scriptUrl
);
70 function printReceive(record
)
73 var data
= record
.traceEvent().args
["data"];
74 if (requestId
!== data
.requestId
)
75 InspectorTest
.addResult("Didn't find matching requestId: " + requestId
);
76 if (data
.statusCode
!== 0)
77 InspectorTest
.addResult("Response received status: " + data
.statusCode
);
80 function printFinish(record
)
83 var data
= record
.traceEvent().args
["data"];
84 if (requestId
!== data
.requestId
)
85 InspectorTest
.addResult("Didn't find matching requestId: " + requestId
);
87 InspectorTest
.addResult("Request failed.");
94 <body onload=
"runTest()">
96 Tests the Timeline API instrumentation of a network resource load