1 var timelineAgentRecordType = {};
3 // Scrub values when printing out these properties in the record or data field.
4 var timelineNonDeterministicProps = {
14 function printTimelineRecords(performActions, typeName, formatter)
17 if (window.layoutTestController)
18 layoutTestController.setTimelineProfilingEnabled(true);
22 evaluateInWebInspector("WebInspector.TimelineAgent.RecordType", function(result) {
23 timelineAgentRecordType = result;
26 evaluateInWebInspector("frontend_getTimelineResults", function(timelineRecords) {
27 if (typeof(timelineRecords) === "string")
28 output("Error fetching Timeline results: " + timelineRecords);
30 for (var i = 0; i < timelineRecords.length; ++i) {
31 var record = timelineRecords[i];
32 if (typeName && record.type === timelineAgentRecordType[typeName])
33 printTimelineRecordProperties(record);
38 if (window.layoutTestController)
39 layoutTestController.setTimelineProfilingEnabled(false);
44 // Dump just the record name, indenting output on separate lines for subrecords
45 function dumpTimelineRecord(record, level)
47 if (typeof level !== "number")
51 for (var i = 0; i < level ; ++i)
52 prefix = "----" + prefix;
54 prefix = prefix + "> ";
55 if (record.type === timelineAgentRecordType.MarkTimeline) {
56 suffix = " : " + record.data.message;
58 output(prefix + timelineAgentTypeToString(record.type) + suffix);
60 var numChildren = record.children ? record.children.length : 0;
61 for (var i = 0; i < numChildren; ++i)
62 dumpTimelineRecord(record.children[i], level + 1);
65 function dumpTimelineRecords(timelineRecords) {
66 for (var i = 0; i < timelineRecords.length; ++i)
67 dumpTimelineRecord(timelineRecords[i], 0);
70 function printTimelineRecordProperties(record)
72 output(timelineAgentTypeToString(record.type) + " Properties:");
73 // Use this recursive routine to print the properties
74 printProps(record, 0);
77 function isNonDeterministicProp(propName)
79 if (timelineNonDeterministicProps[propName])
84 function printProps(record, level)
86 var props = new Array();
87 for (var prop in record) {
92 for (var i = 0; i < level ; i++) {
93 prefix = prefix + "-";
96 prefix = prefix + " ";
97 for (var prop in props) {
98 var propName = props[prop];
99 var propValue = record[propName];
100 if (isNonDeterministicProp(propName))
101 output(prefix + propName + " : " + (propValue === undefined ? "<undefined>" : " * DEFINED *"));
102 else if (typeof propValue === "object") {
103 output(prefix + propName + " : {");
104 printProps(propValue, level + 1);
105 output(prefix + "}");
107 output(prefix + propName + " : " + propValue);
111 function timelineAgentTypeToString(numericType)
113 for (var prop in timelineAgentRecordType) {
114 if (timelineAgentRecordType[prop] === numericType)
120 // Injected into Inspector window
121 function frontend_getTimelineResults() {
123 function addRecords(records)
127 for (var i = 0; i < records.length; ++i) {
128 result.push(records[i].record);
129 addRecords(records[i].children);
132 addRecords(WebInspector.panels.timeline._records);