2010-05-03 Abhishek Arya <inferno@chromium.org>
[WebKit-https.git] / LayoutTests / inspector / timeline-test.js
index c32fbfd..6e50b35 100644 (file)
@@ -5,9 +5,16 @@ var timelineNonDeterministicProps = {
     children : 1,
     endTime : 1, 
     height : 1,
+    identifier : 1,
     startTime : 1,
     width : 1,
-    url : 1
+    callerScriptName: 1,
+    callerScriptLine: 1,
+    callerFunctionName: 1,
+    url : 1,
+    usedHeapSize: 1,
+    totalHeapSize: 1,
+    mimeType : 1
 };
 
 function printTimelineRecords(performActions, typeName, formatter)
@@ -23,19 +30,25 @@ function printTimelineRecords(performActions, typeName, formatter)
     });
 
     evaluateInWebInspector("frontend_getTimelineResults", function(timelineRecords) {
-        if (typeof(timelineRecords) === "string")
-            output("Error fetching Timeline results: " + timelineRecords);
-        else {
-            for (var i = 0; i < timelineRecords.length; ++i) {
-                if (typeName && timelineRecords[i].type === timelineAgentRecordType[typeName])
-                    printTimelineRecordProperties(timelineRecords[i]);
-                if (formatter)
-                    formatter(timelineRecords[i]);
+        try {
+            if (typeof(timelineRecords) === "string")
+                output("Error fetching Timeline results: " + timelineRecords);
+            else {
+                for (var i = 0; i < timelineRecords.length; ++i) {
+                    var record = timelineRecords[i];
+                    if (typeName && record.type === timelineAgentRecordType[typeName])
+                        printTimelineRecordProperties(record);
+                    if (formatter)
+                        formatter(record);
+                }
             }
+            if (window.layoutTestController)
+                layoutTestController.setTimelineProfilingEnabled(false);
+            notifyDone();
+        } catch (e) {
+            console.log("An exception was caught: " + e.toString());
+            notifyDone(e.toString());
         }
-        if (window.layoutTestController)
-            layoutTestController.setTimelineProfilingEnabled(false);
-        notifyDone();
     });
 }
 
@@ -118,9 +131,15 @@ function timelineAgentTypeToString(numericType)
 // Injected into Inspector window
 function frontend_getTimelineResults() {
     var result = [];
-    var items = WebInspector.panels.timeline._items;
-    for (var i = 0; i < items.length; ++i) {
-        result.push(items[i].record);
+    function addRecords(records)
+    {
+        if (!records)
+            return;
+        for (var i = 0; i < records.length; ++i) {
+            result.push(records[i].originalRecordForTests);
+            addRecords(records[i].children);
+        }
     }
+    addRecords(WebInspector.panels.timeline._rootRecord.children);
     return result;
 }