Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / timeline / timeline-coalescing.html
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 function initialize_TimelineCoalescing()
8 {
9
10 InspectorTest.dumpStats = function(record)
11 {
12     if (record.type() === "Root")
13         return "";
14     var aggregatedStats = record.aggregatedStats();
15     var timeByCategory = "";
16     
17     for (category in aggregatedStats) {
18         if (timeByCategory)
19             timeByCategory += ", ";
20         timeByCategory += category + ": " + aggregatedStats[category].toFixed(5);
21     }
22     var duration = (record.endTime() - record.startTime()).toFixed(5);
23     var durationTillLastChild = (record.endTime() - record.startTime()).toFixed(5);
24     return "duration: " + duration + ":" + durationTillLastChild + (timeByCategory ? " (" + timeByCategory + ")" : "");
25 }
26
27 }
28
29 function test()
30 {
31     var records = [
32         // Assure we coalesce records with sort interval and don't coalesce records that stand apart.
33         {"startTime": 1000.000,"data":{},"endTime":1099.999,"type":"Program","children":[
34             {"startTime":1000.001, "endTime":1099.9,"type":"Layout","frameId":"2","data":{},
35             "stackTrace": [
36                 {"functionName":"func","url":"http://example.com","lineNumber":42,"columnNumber":1}
37             ]}
38         ]},
39         {"startTime":1100.000,"data":{},"endTime":1199.999,"type":"Program","children":[
40             {"startTime":1100.001, "endTime":1199.9,"type":"Layout","frameId":"2","data":{}}
41         ]},
42         {"startTime":1200.000,"data":{},"endTime":1299.999,"type":"Program","children":[
43             {"startTime":1200.001, "endTime":1299.9,"type":"Layout","frameId":"2","data":{}}
44         ]},
45         {"startTime":1300.000,"data":{},"endTime":1399.999,"type":"Program","children":[
46             {"startTime":1305.001, "endTime":1399.9,"type":"Layout","frameId":"2","data":{}}
47         ]},
48
49         // Assure we do coalesce on levels lower than root, but do not coalesce between different parents.
50         {"startTime":2000.000,"data":{},"endTime":2399.999,"type":"Program","children":[
51             {"startTime":2000.001,"data":{},"endTime":2199.998,"type":"FunctionCall","children":[
52                 {"startTime":2000.002, "endTime":2099.9,"type":"DecodeImage","frameId":"2","data":{}},
53                 {"startTime":2100.000, "endTime":2199.9,"type":"DecodeImage","frameId":"2","data":{}}
54             ]},
55             {"startTime":2200.001,"data":{},"endTime":2399.998,"type":"FunctionCall","children":[
56                 {"startTime":2200.002, "endTime":2299.9,"type":"DecodeImage","frameId":"2","data":{}},
57                 {"startTime":2300.000, "endTime":2399.9,"type":"DecodeImage","frameId":"2","data":{}}
58             ]},
59         ]},
60
61         // Assure we only coalesce timestamp records with the same message.
62         {"startTime":3100.000,"data":{},"endTime":3199.999,"type":"Program","children":[
63             {"startTime":3100.001, "endTime":3199.9,"type":"Rasterize","frameId":"2","data":{ message: "foo" }}
64         ]},
65         {"startTime":3200.000,"data":{},"endTime":3299.999,"type":"Program","children":[
66             {"startTime":3200.001, "endTime":3299.9,"type":"Rasterize","frameId":"2","data":{ message: "foo" }}
67         ]},
68         {"startTime":3300.000,"data":{},"endTime":3399.999,"type":"Program","children":[
69             {"startTime":3300.001, "endTime":3399.9,"type":"Rasterize","frameId":"2","data":{ message: "bar" }}
70         ]},
71
72         // Assure we only coalesce event records with the same type.
73         {"startTime":4100.000,"data":{},"endTime":4199.999,"type":"Program","children":[
74             {"startTime":4100.001, "endTime":4199.9,"type":"Paint","frameId":"2","data":{ type: "mouseover" }}
75         ]},
76         {"startTime":4200.000,"data":{},"endTime":4299.999,"type":"Program","children":[
77             {"startTime":4200.001, "endTime":4299.9,"type":"Paint","frameId":"2","data":{ type: "mouseover" }}
78         ]},
79         {"startTime":4300.000,"data":{},"endTime":4399.999,"type":"Program","children":[
80             {"startTime":4300.001, "endTime":4399.9,"type":"Paint","frameId":"2","data":{ type: "keydown" }}
81         ]}
82     ];
83
84     InspectorTest.loadTimelineRecords(records);
85
86     var rootRecord = InspectorTest.timelinePresentationModel().rootRecord();
87     InspectorTest.dumpPresentationRecord(rootRecord, InspectorTest.dumpStats);
88     var coalesced = rootRecord.presentationChildren()[0];
89     InspectorTest.addResult("coalesced record's hasWarnings(): " + coalesced.hasWarnings());
90     InspectorTest.addResult("coalesced record's childHasWarnings(): " + coalesced.childHasWarnings());
91     InspectorTest.completeTest();
92 }
93
94 </script>
95 </head>
96
97 <body onload="runTest()">
98 <p>
99 Test timeline records coalescing
100 </p>
101
102 </body>
103 </html>