3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/console-test.js"></script>
5 <script src=
"../../http/tests/inspector/timeline-test.js"></script>
8 function startStopTimeline()
10 console
.timeStamp("timestamp 0");
11 console
.timeline("one");
12 console
.timeStamp("timestamp 1");
13 console
.timelineEnd("one");
14 console
.timeStamp("timestamp 2");
17 function startStopMultiple()
19 console
.timeStamp("timestamp 0");
20 console
.timeline("one");
21 console
.timeStamp("timestamp 1");
22 console
.timeline("one");
23 console
.timeline("two");
24 console
.timeline("two");
25 console
.timelineEnd("two");
26 console
.timeStamp("timestamp 2");
27 console
.timelineEnd("one");
28 console
.timeStamp("timestamp 3");
29 console
.timelineEnd("two");
30 console
.timeStamp("timestamp 4");
31 console
.timelineEnd("one");
32 console
.timeStamp("timestamp 5");
35 function startMultiple()
37 console
.timeStamp("timestamp 0");
38 console
.timeline("one");
39 console
.timeStamp("timestamp 1");
40 console
.timeline("two");
41 console
.timeStamp("timestamp 2");
46 console
.timeStamp("timestamp 3");
47 console
.timelineEnd("two");
48 console
.timeStamp("timestamp 4");
53 console
.timeStamp("timestamp 5");
54 console
.timelineEnd("one");
55 console
.timeStamp("timestamp 6 - FAIL");
58 function stopUnknown()
60 console
.timeStamp("timestamp 0");
61 console
.timeline("one");
62 console
.timeStamp("timestamp 1");
63 console
.timelineEnd("two");
64 console
.timeStamp("timestamp 2");
65 console
.timelineEnd("one");
66 console
.timeStamp("timestamp 3");
69 function startTimeline()
71 console
.timeStamp("timestamp 0");
72 console
.timeline("one");
73 console
.timeStamp("timestamp 1");
74 console
.timeline("two");
75 console
.timeStamp("timestamp 2");
80 var panel
= WebInspector
.panels
.timeline
;
81 panel
._model
._currentTarget
= WebInspector
.targetManager
.mainTarget();
83 InspectorTest
.runTestSuite([
84 function testStartStopTimeline(next
)
86 InspectorTest
.evaluateWithTimeline("startStopTimeline()", allEventsReceived
);
88 function allEventsReceived()
90 printTimelineAndTimestampEvents();
95 function testStartStopMultiple(next
)
97 InspectorTest
.evaluateWithTimeline("startStopMultiple()", allEventsReceived
);
99 function allEventsReceived()
101 printTimelineAndTimestampEvents();
106 function testStartMultipleStopInsideEvals(next
)
108 InspectorTest
.startTimeline(step1
);
112 InspectorTest
.evaluateInPage("startMultiple()", step2
);
117 InspectorTest
.evaluateInPage("stopTwo()", step3
);
122 InspectorTest
.evaluateInPage("stopOne()", step4
);
127 InspectorTest
.stopTimeline(finish
);
132 printTimelineAndTimestampEvents();
137 function testStopUnknown(next
)
139 InspectorTest
.evaluateWithTimeline("stopUnknown()", allEventsReceived
);
141 function allEventsReceived()
143 printTimelineAndTimestampEvents();
148 function testStartFromPanel(next
)
150 panel
._model
.addEventListener(WebInspector
.TimelineModel
.Events
.RecordingStarted
, recordingStarted
);
151 panel
._model
.addEventListener(WebInspector
.TimelineModel
.Events
.RecordingStopped
, finish
);
152 panel
._toggleTimelineButtonClicked();
154 function recordingStarted()
156 panel
._model
.removeEventListener(WebInspector
.TimelineModel
.Events
.RecordingStarted
, recordingStarted
);
157 InspectorTest
.evaluateInPage("startStopTimeline()", step2
);
162 panel
._toggleTimelineButtonClicked();
167 printTimelineAndTimestampEvents();
168 panel
._model
.removeEventListener(WebInspector
.TimelineModel
.Events
.RecordingStopped
, finish
);
173 function testStopFromPanel(next
)
175 panel
._model
.addEventListener(WebInspector
.TimelineModel
.Events
.RecordingStopped
, finish
);
177 InspectorTest
.startTimeline(step1
);
181 InspectorTest
.evaluateInPage("startTimeline()", step2
);
186 panel
._toggleTimelineButtonClicked();
191 printTimelineAndTimestampEvents();
192 panel
._model
.removeEventListener(WebInspector
.TimelineModel
.Events
.RecordingStopped
, finish
);
197 function testRacyStart(next
)
199 panel
._model
.addEventListener(WebInspector
.TimelineModel
.Events
.RecordingStarted
, recordingStarted
);
200 panel
._model
.addEventListener(WebInspector
.TimelineModel
.Events
.RecordingStopped
, finish
);
201 panel
._toggleTimelineButtonClicked();
203 function recordingStarted()
205 panel
._model
.removeEventListener(WebInspector
.TimelineModel
.Events
.RecordingStarted
, recordingStarted
);
206 InspectorTest
.evaluateInPage("startTimeline()", didEvaluate
);
209 function didEvaluate()
211 panel
._toggleTimelineButtonClicked();
216 printTimelineAndTimestampEvents();
217 panel
._model
.removeEventListener(WebInspector
.TimelineModel
.Events
.RecordingStopped
, finish
);
222 function testRacyStart2(next
)
224 panel
._model
.addEventListener(WebInspector
.TimelineModel
.Events
.RecordingStarted
, recordingStarted
);
225 panel
._model
.addEventListener(WebInspector
.TimelineModel
.Events
.RecordingStopped
, finish
);
227 panel
._toggleTimelineButtonClicked();
229 function recordingStarted()
231 panel
._model
.removeEventListener(WebInspector
.TimelineModel
.Events
.RecordingStarted
, recordingStarted
);
232 InspectorTest
.evaluateInPage("startTimeline()", didEvaluate
);
235 function didEvaluate()
237 // Fool listener order execution.
238 setTimeout(panel
._toggleTimelineButtonClicked
.bind(panel
));
243 panel
._model
.removeEventListener(WebInspector
.TimelineModel
.Events
.RecordingStopped
, finish
);
244 printTimelineAndTimestampEvents();
250 function printTimelineAndTimestampEvents() {
251 panel
._tracingModel
.sortedProcesses().forEach(function(process
)
253 process
.sortedThreads().forEach(function(thread
)
255 thread
.events().forEach(function(event
)
257 if (event
.hasCategory(WebInspector
.TracingModel
.ConsoleEventCategory
))
258 InspectorTest
.addResult(event
.name
);
259 else if (event
.name
=== WebInspector
.TimelineModel
.RecordType
.TimeStamp
)
260 InspectorTest
.addResult(event
.args
["data"]["message"]);
270 <body onload=
"runTest()">
272 Tests console.timeline and timelineEnd commands.