Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector-protocol / timeline / timeline-start-bufferEvents.html
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
5
6 function testFunction()
7 {
8     console.timeStamp("Timestamp");
9 }
10
11 function test()
12 {
13     InspectorTest.eventHandler["Timeline.eventRecorded"] = eventRecorded;
14     InspectorTest.log("Recording started");
15     InspectorTest.sendCommand("Timeline.start", { bufferEvents: true }, onStart);
16
17     function onStart(response)
18     {
19         InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" }, didEvaluate);
20     }
21
22     function didEvaluate(response)
23     {
24         InspectorTest.sendCommand("Timeline.stop", {}, onStop);
25     }
26
27     function eventRecorded(event)
28     {
29         InspectorTest.log("FAIL: event recorded: " + event.params.record.type);
30     }
31
32     function onStop(response)
33     {
34         InspectorTest.log("Recording stopped");
35         InspectorTest.log("Events:");
36         var events = response.result.events;
37         for (var i = 0; i < events.length; ++i)
38             dump(events[i], "");
39         InspectorTest.completeTest();
40     }
41
42     function dump(event, prefix)
43     {
44         var eventTypes = { "FunctionCall":true, "TimeStamp":true, "TimerInstall":true, "TimerFire":true };
45         if (event.type in eventTypes)
46             InspectorTest.log(prefix + event.type);
47         for (var i = 0; event.children && i < event.children.length; ++i)
48             dump(event.children[i], "    " + prefix);
49     }
50 }
51 </script>
52 </head>
53 <body onLoad="runTest();">
54 </body>
55 </html>