Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / tracing / console-timeline.html
1 <html>
2 <head>
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>
6 <script>
7
8 function startStopTimeline()
9 {
10     console.timeStamp("timestamp 0");
11     console.timeline("one");
12     console.timeStamp("timestamp 1");
13     console.timelineEnd("one");
14     console.timeStamp("timestamp 2");
15 }
16
17 function startStopMultiple()
18 {
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");
33 }
34
35 function startMultiple()
36 {
37     console.timeStamp("timestamp 0");
38     console.timeline("one");
39     console.timeStamp("timestamp 1");
40     console.timeline("two");
41     console.timeStamp("timestamp 2");
42 }
43
44 function stopTwo()
45 {
46     console.timeStamp("timestamp 3");
47     console.timelineEnd("two");
48     console.timeStamp("timestamp 4");
49 }
50
51 function stopOne()
52 {
53     console.timeStamp("timestamp 5");
54     console.timelineEnd("one");
55     console.timeStamp("timestamp 6 - FAIL");
56 }
57
58 function stopUnknown()
59 {
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");
67 }
68
69 function startTimeline()
70 {
71     console.timeStamp("timestamp 0");
72     console.timeline("one");
73     console.timeStamp("timestamp 1");
74     console.timeline("two");
75     console.timeStamp("timestamp 2");
76 }
77
78 function test()
79 {
80     var panel = WebInspector.panels.timeline;
81     panel._model._currentTarget = WebInspector.targetManager.mainTarget();
82
83     InspectorTest.runTestSuite([
84         function testStartStopTimeline(next)
85         {
86             InspectorTest.evaluateWithTimeline("startStopTimeline()", allEventsReceived);
87
88             function allEventsReceived()
89             {
90                 printTimelineAndTimestampEvents();
91                 next();
92             }
93         },
94
95         function testStartStopMultiple(next)
96         {
97             InspectorTest.evaluateWithTimeline("startStopMultiple()", allEventsReceived);
98
99             function allEventsReceived()
100             {
101                 printTimelineAndTimestampEvents();
102                 next();
103             }
104         },
105
106         function testStartMultipleStopInsideEvals(next)
107         {
108             InspectorTest.startTimeline(step1);
109
110             function step1()
111             {
112                 InspectorTest.evaluateInPage("startMultiple()", step2);
113             }
114
115             function step2()
116             {
117                 InspectorTest.evaluateInPage("stopTwo()", step3);
118             }
119
120             function step3()
121             {
122                 InspectorTest.evaluateInPage("stopOne()", step4);
123             }
124
125             function step4()
126             {
127                 InspectorTest.stopTimeline(finish);
128             }
129
130             function finish()
131             {
132                 printTimelineAndTimestampEvents();
133                 next();
134             }
135        },
136
137         function testStopUnknown(next)
138         {
139             InspectorTest.evaluateWithTimeline("stopUnknown()", allEventsReceived);
140
141             function allEventsReceived()
142             {
143                 printTimelineAndTimestampEvents();
144                 next();
145             }
146         },
147
148         function testStartFromPanel(next)
149         {
150             panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStarted, recordingStarted);
151             panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, finish);
152             panel._toggleTimelineButtonClicked();
153
154             function recordingStarted()
155             {
156                 panel._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStarted, recordingStarted);
157                 InspectorTest.evaluateInPage("startStopTimeline()", step2);
158             }
159
160             function step2()
161             {
162                 panel._toggleTimelineButtonClicked();
163             }
164
165             function finish()
166             {
167                 printTimelineAndTimestampEvents();
168                 panel._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, finish);
169                 next();
170             }
171         },
172
173         function testStopFromPanel(next)
174         {
175             panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, finish);
176
177             InspectorTest.startTimeline(step1);
178
179             function step1()
180             {
181                 InspectorTest.evaluateInPage("startTimeline()", step2);
182             }
183
184             function step2()
185             {
186                 panel._toggleTimelineButtonClicked();
187             }
188
189             function finish()
190             {
191                 printTimelineAndTimestampEvents();
192                 panel._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, finish);
193                 next();
194             }
195        },
196
197         function testRacyStart(next)
198         {
199             panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, finish);
200             panel._toggleTimelineButtonClicked();
201             InspectorTest.evaluateInPage("startTimeline()", timelineStarted);
202
203             function timelineStarted()
204             {
205                 panel._toggleTimelineButtonClicked();
206             }
207
208             function finish()
209             {
210                 printTimelineAndTimestampEvents();
211                 panel._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, finish);
212                 next();
213             }
214         },
215
216         function testRacyStart2(next)
217         {
218             panel._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStopped, finish);
219
220             panel._toggleTimelineButtonClicked();
221             InspectorTest.evaluateInPage("startTimeline()", timelineStarted);
222
223             function timelineStarted()
224             {
225                 // Fool listener order execution.
226                 setTimeout(panel._toggleTimelineButtonClicked.bind(panel));
227             }
228
229             function finish()
230             {
231                 panel._model.removeEventListener(WebInspector.TimelineModel.Events.RecordingStopped, finish);
232                 printTimelineAndTimestampEvents();
233                 next();
234             }
235         }
236     ]);
237
238     function printTimelineAndTimestampEvents() {
239         panel._tracingModel.sortedProcesses().forEach(function(process)
240         {
241             process.sortedThreads().forEach(function(thread)
242             {
243                 thread.events().forEach(function(event)
244                 {
245                    if (event.category === WebInspector.TracingModel.ConsoleEventCategory)
246                        InspectorTest.addResult(event.name);
247                    else if (event.name === WebInspector.TracingTimelineModel.RecordType.TimeStamp)
248                        InspectorTest.addResult(event.args["data"]["message"]);
249                 });
250             });
251         });
252     }
253 }
254
255 </script>
256 </head>
257
258 <body onload="runTest()">
259 <p>
260 Tests console.timeline and timelineEnd commands.
261 </p>
262
263 </body>
264 </html>