Web Inspector: sometimes ReceiveResponse event is attached to wrong parent.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jul 2011 15:19:14 +0000 (15:19 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jul 2011 15:19:14 +0000 (15:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65016

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test: inspector/timeline/timeline-receive-response-event.html

* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didInstallTimer):
(WebCore::InspectorTimelineAgent::didRemoveTimer):
(WebCore::InspectorTimelineAgent::didScheduleResourceRequest):
(WebCore::InspectorTimelineAgent::didFinishLoadingResource):
(WebCore::InspectorTimelineAgent::didTimeStamp):
(WebCore::InspectorTimelineAgent::didMarkDOMContentEvent):
(WebCore::InspectorTimelineAgent::didMarkLoadEvent):
(WebCore::InspectorTimelineAgent::appendRecord):
* inspector/InspectorTimelineAgent.h:
* inspector/front-end/TimelinePanel.js:
(WebInspector.TimelinePanel.prototype._innerAddRecordToTimeline):

LayoutTests:

* http/tests/inspector/inspector-test.js:
(initialize_InspectorTest.InspectorTest.dump):
* inspector/timeline/resources/anImage.png: Added.
* inspector/timeline/resources/anotherImage.png: Added.
* inspector/timeline/timeline-receive-response-event-expected.txt: Added.
* inspector/timeline/timeline-receive-response-event.html: Added.
* platform/chromium/inspector/timeline/timeline-receive-response-event-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@91567 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/inspector-test.js
LayoutTests/inspector/timeline/resources/anImage.png [new file with mode: 0644]
LayoutTests/inspector/timeline/resources/anotherImage.png [new file with mode: 0644]
LayoutTests/inspector/timeline/timeline-receive-response-event-expected.txt [new file with mode: 0644]
LayoutTests/inspector/timeline/timeline-receive-response-event.html [new file with mode: 0644]
LayoutTests/platform/chromium/inspector/timeline/timeline-receive-response-event-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/front-end/TimelinePanel.js

index 527480c89e2f564a038ed153a6c70518311df685..1c7c8a905b355fcb6a3489408b759b8f487efea5 100644 (file)
@@ -1,3 +1,18 @@
+2011-07-22  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: sometimes ReceiveResponse event is attached to wrong parent.
+        https://bugs.webkit.org/show_bug.cgi?id=65016
+
+        Reviewed by Yury Semikhatsky.
+
+        * http/tests/inspector/inspector-test.js:
+        (initialize_InspectorTest.InspectorTest.dump):
+        * inspector/timeline/resources/anImage.png: Added.
+        * inspector/timeline/resources/anotherImage.png: Added.
+        * inspector/timeline/timeline-receive-response-event-expected.txt: Added.
+        * inspector/timeline/timeline-receive-response-event.html: Added.
+        * platform/chromium/inspector/timeline/timeline-receive-response-event-expected.txt: Added.
+
 2011-07-22  Kentaro Hara  <haraken@google.com>
 
         REGRESSION(r89535): Form reset does not repaint a file upload control.
index e345a14dd4b26a8acbfa5991ba924c3c2bc667fa..b37740ace0ff6913e60ee979a00ea3ad4f097965 100644 (file)
@@ -158,6 +158,10 @@ InspectorTest.addArray = function(array, nondeterministicProps, prefix, firstLin
 InspectorTest.dump = function(value, nondeterministicProps, prefix, prefixWithName)
 {
     prefixWithName = prefixWithName || prefix;
+    if (prefixWithName && prefixWithName.length > 80) {
+        InspectorTest.addResult(prefixWithName + "was skipped due to prefix length limit");
+        return;
+    }
     if (value === null)
         InspectorTest.addResult(prefixWithName + "null");
     else if (value instanceof Array)
diff --git a/LayoutTests/inspector/timeline/resources/anImage.png b/LayoutTests/inspector/timeline/resources/anImage.png
new file mode 100644 (file)
index 0000000..2d1a0e6
Binary files /dev/null and b/LayoutTests/inspector/timeline/resources/anImage.png differ
diff --git a/LayoutTests/inspector/timeline/resources/anotherImage.png b/LayoutTests/inspector/timeline/resources/anotherImage.png
new file mode 100644 (file)
index 0000000..2d1a0e6
Binary files /dev/null and b/LayoutTests/inspector/timeline/resources/anotherImage.png differ
diff --git a/LayoutTests/inspector/timeline/timeline-receive-response-event-expected.txt b/LayoutTests/inspector/timeline/timeline-receive-response-event-expected.txt
new file mode 100644 (file)
index 0000000..8e48ff4
--- /dev/null
@@ -0,0 +1,13 @@
+Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc.
+
+ResourceSendRequest
+    ResourceReceiveResponse
+    ResourceReceivedData
+    ResourceFinish
+ResourceSendRequest
+    ResourceReceiveResponse
+    ResourceReceivedData
+    ResourceFinish
+EventDispatch
+EventDispatch
+
diff --git a/LayoutTests/inspector/timeline/timeline-receive-response-event.html b/LayoutTests/inspector/timeline/timeline-receive-response-event.html
new file mode 100644 (file)
index 0000000..84edf1f
--- /dev/null
@@ -0,0 +1,69 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="timeline-test.js"></script>
+<script>
+
+function performActions()
+{
+    var image = new Image();
+    image.onload = bar;
+    image.src = "resources/anImage.png";
+
+    function bar() {
+        var image = new Image();
+        image.onload = function() { layoutTestController.evaluateInWebInspector(0, "window.step2()"); }
+        image.src = "resources/anotherImage.png";
+    }
+}
+
+function test()
+{
+    WebInspector.showPanel("timeline");
+    WebInspector.panels.timeline.toggleTimelineButton.toggled = true;
+    TimelineAgent.start(step1);
+
+    function step1()
+    {
+        InspectorTest.evaluateInPage("performActions()");
+    }
+
+    window.step2 = function()
+    {
+        TimelineAgent.stop(step3);
+    }
+
+    function step3()
+    {
+        function dumpFormattedRecord(record, prefix)
+        {
+             prefix = prefix || "";
+             InspectorTest.addResult(prefix + record.type);
+             if (record._children) {
+                 var childPrefix = prefix + "    ";
+                 for (var i = 0; i < record._children.length; ++i)
+                     dumpFormattedRecord(record._children[i], childPrefix);
+             }
+        }
+        WebInspector.panels.timeline.toggleTimelineButton.toggled = false;
+
+        var records = WebInspector.panels.timeline._rootRecord.children;
+        for (var i = 0; i < records.length; ++i)
+            dumpFormattedRecord(records[i]);
+        InspectorTest.completeTest();
+    }
+}
+
+if (!window.layoutTestController)
+    setTimeout(performActions, 3000);
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc.
+</p>
+
+</body>
+</html>
diff --git a/LayoutTests/platform/chromium/inspector/timeline/timeline-receive-response-event-expected.txt b/LayoutTests/platform/chromium/inspector/timeline/timeline-receive-response-event-expected.txt
new file mode 100644 (file)
index 0000000..969b493
--- /dev/null
@@ -0,0 +1,15 @@
+Tests the Timeline API instrumentation of a SendRequest, ReceiveResponse etc.
+
+ResourceSendRequest
+    ResourceReceiveResponse
+    ResourceReceivedData
+    ResourceFinish
+ResourceSendRequest
+    ResourceReceiveResponse
+    ResourceReceivedData
+    ResourceFinish
+EventDispatch
+    FunctionCall
+EventDispatch
+    FunctionCall
+
index 702b1e91e042a6e2fbb401d9649763def90f47df..a9e38b2282f161c8b9afe5d2f1ab2768bb7afa7a 100644 (file)
@@ -1,3 +1,25 @@
+2011-07-22  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: sometimes ReceiveResponse event is attached to wrong parent.
+        https://bugs.webkit.org/show_bug.cgi?id=65016
+
+        Reviewed by Yury Semikhatsky.
+
+        Test: inspector/timeline/timeline-receive-response-event.html
+
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::didInstallTimer):
+        (WebCore::InspectorTimelineAgent::didRemoveTimer):
+        (WebCore::InspectorTimelineAgent::didScheduleResourceRequest):
+        (WebCore::InspectorTimelineAgent::didFinishLoadingResource):
+        (WebCore::InspectorTimelineAgent::didTimeStamp):
+        (WebCore::InspectorTimelineAgent::didMarkDOMContentEvent):
+        (WebCore::InspectorTimelineAgent::didMarkLoadEvent):
+        (WebCore::InspectorTimelineAgent::appendRecord):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/front-end/TimelinePanel.js:
+        (WebInspector.TimelinePanel.prototype._innerAddRecordToTimeline):
+
 2011-07-22  Kentaro Hara  <haraken@google.com>
 
         REGRESSION(r89535): Form reset does not repaint a file upload control.
index 60b80d8736254b345d6ac3ffcf366d5c123d7632..ba95f865c36e7bf7691cf5618cf7a69c5a0410b4 100644 (file)
@@ -233,18 +233,12 @@ void InspectorTimelineAgent::didWriteHTML(unsigned int endLine)
 
 void InspectorTimelineAgent::didInstallTimer(int timerId, int timeout, bool singleShot)
 {
-    pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
-    record->setObject("data", TimelineRecordFactory::createTimerInstallData(timerId, timeout, singleShot));
-    addRecordToTimeline(record.release(), TimelineRecordType::TimerInstall);
+    appendRecord(TimelineRecordFactory::createTimerInstallData(timerId, timeout, singleShot), TimelineRecordType::TimerInstall);
 }
 
 void InspectorTimelineAgent::didRemoveTimer(int timerId)
 {
-    pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
-    record->setObject("data", TimelineRecordFactory::createGenericTimerData(timerId));
-    addRecordToTimeline(record.release(), TimelineRecordType::TimerRemove);
+    appendRecord(TimelineRecordFactory::createGenericTimerData(timerId), TimelineRecordType::TimerRemove);
 }
 
 void InspectorTimelineAgent::willFireTimer(int timerId)
@@ -289,11 +283,7 @@ void InspectorTimelineAgent::didEvaluateScript()
 
 void InspectorTimelineAgent::didScheduleResourceRequest(const String& url)
 {
-    pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
-    record->setObject("data", TimelineRecordFactory::createScheduleResourceRequestData(url));
-    record->setString("type", TimelineRecordType::ScheduleResourceRequest);
-    addRecordToTimeline(record.release(), TimelineRecordType::ScheduleResourceRequest);
+    appendRecord(TimelineRecordFactory::createScheduleResourceRequestData(url), TimelineRecordType::ScheduleResourceRequest);
 }
 
 void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, const ResourceRequest& request)
@@ -331,36 +321,22 @@ void InspectorTimelineAgent::didReceiveResourceResponse()
 
 void InspectorTimelineAgent::didFinishLoadingResource(unsigned long identifier, bool didFail, double finishTime)
 {
-    pushGCEventRecords();
-    // Sometimes network stack can provide for us exact finish loading time. In the other case we will use currentTime.
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
-    String resourceId = IdentifiersFactory::resourceId(identifier);
-    record->setObject("data", TimelineRecordFactory::createResourceFinishData(resourceId, didFail, finishTime * 1000));
-    record->setString("type", TimelineRecordType::ResourceFinish);
-    setHeapSizeStatistic(record.get());
-    m_frontend->eventRecorded(record.release());
+    appendRecord(TimelineRecordFactory::createResourceFinishData(IdentifiersFactory::resourceId(identifier), didFail, finishTime * 1000), TimelineRecordType::ResourceFinish);
 }
 
 void InspectorTimelineAgent::didTimeStamp(const String& message)
 {
-    pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
-    record->setObject("data", TimelineRecordFactory::createTimeStampData(message));
-    addRecordToTimeline(record.release(), TimelineRecordType::TimeStamp);
+    appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRecordType::TimeStamp);
 }
 
 void InspectorTimelineAgent::didMarkDOMContentEvent()
 {
-    pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
-    addRecordToTimeline(record.release(), TimelineRecordType::MarkDOMContent);
+    appendRecord(InspectorObject::create(), TimelineRecordType::TimeStamp);
 }
 
 void InspectorTimelineAgent::didMarkLoadEvent()
 {
-    pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
-    addRecordToTimeline(record.release(), TimelineRecordType::MarkLoad);
+    appendRecord(InspectorObject::create(), TimelineRecordType::MarkLoad);
 }
 
 void InspectorTimelineAgent::didCommitLoad()
@@ -416,6 +392,15 @@ InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentin
 {
 }
 
+void InspectorTimelineAgent::appendRecord(PassRefPtr<InspectorObject> data, const String& type)
+{
+    pushGCEventRecords();
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
+    record->setObject("data", data);
+    record->setString("type", type);
+    addRecordToTimeline(record.release(), type);
+}
+
 void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, const String& type)
 {
     pushGCEventRecords();
index 91f49420e63e2f46e6920cadfc2e95f4a604de9b..8921d4eece4e5bf73bc668ac2cb7caf3d6c082a4 100644 (file)
@@ -139,6 +139,7 @@ private:
     void setHeapSizeStatistic(InspectorObject* record);
         
     void didCompleteCurrentRecord(const String& type);
+    void appendRecord(PassRefPtr<InspectorObject> data, const String& type);
 
     void addRecordToTimeline(PassRefPtr<InspectorObject>, const String& type);
 
index c07f15a6cc23933cd3c099ade5fbd660892d7b99..db28473d17f94e27ff9eb721f2dc0ef768d3b60e 100644 (file)
@@ -404,7 +404,10 @@ WebInspector.TimelinePanel.prototype = {
         var recordTypes = WebInspector.TimelineAgent.RecordType;
         if (record.type === recordTypes.MarkDOMContent || record.type === recordTypes.MarkLoad)
             parentRecord = null; // No bar entry for load events.
-        else if (parentRecord === this._rootRecord) {
+        else if (parentRecord === this._rootRecord ||
+                 record.type === recordTypes.ResourceReceiveResponse ||
+                 record.type === recordTypes.ResourceFinish ||
+                 record.type === recordTypes.ResourceReceivedData) {
             var newParentRecord = this._findParentRecord(record);
             if (newParentRecord) {
                 parentRecord = newParentRecord;