2011-04-29 Vsevolod Vlasov <vsevik@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2011 11:43:30 +0000 (11:43 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2011 11:43:30 +0000 (11:43 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: Hyperlink Auditing (ping) requests are not shown in network panel
        https://bugs.webkit.org/show_bug.cgi?id=58794

        Added ping requests to network panel.

        * http/tests/inspector/network/ping-expected.txt: Added.
        * http/tests/inspector/network/ping.html: Added.
2011-04-29  Vsevolod Vlasov  <vsevik@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: Hyperlink Auditing (ping) requests are not shown in network panel
        https://bugs.webkit.org/show_bug.cgi?id=58794

        Added ping requests to network panel.

        Test: http/tests/inspector/network/ping.html

        * English.lproj/localizedStrings.js:
        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::continueAfterPingLoaderImpl):
        * inspector/InspectorInstrumentation.h:
        (WebCore::InspectorInstrumentation::continueAfterPingLoader):
        * inspector/front-end/NetworkPanel.js:
        (WebInspector.NetworkDataGridNode.prototype.refreshResource):
        (WebInspector.NetworkDataGridNode.prototype._refreshStatusCell):
        (WebInspector.NetworkDataGridNode.prototype._refreshTypeCell):
        * inspector/front-end/Resource.js:
        (WebInspector.Resource.prototype.get formParameters):
        (WebInspector.Resource.prototype.requestContentType):
        (WebInspector.Resource.prototype.isPingRequest):
        * loader/PingLoader.cpp:
        (WebCore::PingLoader::PingLoader):
        * loader/PingLoader.h:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/ping-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/network/ping.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/Resource.js
Source/WebCore/loader/PingLoader.cpp
Source/WebCore/loader/PingLoader.h

index 3f30332..2b5678d 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-29  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Hyperlink Auditing (ping) requests are not shown in network panel
+        https://bugs.webkit.org/show_bug.cgi?id=58794
+
+        Added ping requests to network panel.
+
+        * http/tests/inspector/network/ping-expected.txt: Added.
+        * http/tests/inspector/network/ping.html: Added.
+
 2011-04-28  Pavel Podivilov  <podivilov@chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/LayoutTests/http/tests/inspector/network/ping-expected.txt b/LayoutTests/http/tests/inspector/network/ping-expected.txt
new file mode 100644 (file)
index 0000000..ac9946a
--- /dev/null
@@ -0,0 +1,7 @@
+ping
+Tests that hyperlink auditing (ping) requests appear in network panel.
+
+http://127.0.0.1:8000/inspector/network/ping.html
+resource.isPingRequest(): true
+resource.requestContentType: text/ping
+
diff --git a/LayoutTests/http/tests/inspector/network/ping.html b/LayoutTests/http/tests/inspector/network/ping.html
new file mode 100644 (file)
index 0000000..8666bd1
--- /dev/null
@@ -0,0 +1,45 @@
+<html>
+<head>
+<script src="../inspector-test.js"></script>
+<script>
+function onload()
+{
+    if (window.layoutTestController)
+        layoutTestController.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
+    runTest();
+}
+
+function navigateLink()
+{
+    var evt = document.createEvent("MouseEvents");
+    evt.initMouseEvent("click");
+    var link = document.getElementById("pingLink");
+    link.dispatchEvent(evt);
+}
+
+function test()
+{
+    InspectorTest.addSniffer(WebInspector.NetworkDispatcher.prototype, "requestWillBeSent", step2);
+    InspectorTest.evaluateInPage("navigateLink()");
+
+    function step2()
+    {
+        // inspector-test.js appears in network panel occasionally in Safari on
+        // Mac, so checking last resource.
+        var resourcesCount = WebInspector.panels.network.resources.length;
+        var resource = WebInspector.panels.network.resources[resourcesCount - 1];
+
+        InspectorTest.addResult(resource.url);
+        InspectorTest.addResult("resource.isPingRequest(): " + resource.isPingRequest());
+        InspectorTest.addResult("resource.requestContentType: " + resource.requestContentType());
+
+        InspectorTest.completeTest();
+    }
+}
+</script>
+</head>
+<body onload="onload()">
+<a id="pingLink" href="#" ping="ping.html">ping</a>
+<p>Tests that hyperlink auditing (ping) requests appear in network panel.</p>
+</body>
+</html>
index 94513ed..206d5c8 100644 (file)
@@ -1,3 +1,31 @@
+2011-04-29  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Hyperlink Auditing (ping) requests are not shown in network panel
+        https://bugs.webkit.org/show_bug.cgi?id=58794
+
+        Added ping requests to network panel.
+
+        Test: http/tests/inspector/network/ping.html
+
+        * English.lproj/localizedStrings.js:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::continueAfterPingLoaderImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::continueAfterPingLoader):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkDataGridNode.prototype.refreshResource):
+        (WebInspector.NetworkDataGridNode.prototype._refreshStatusCell):
+        (WebInspector.NetworkDataGridNode.prototype._refreshTypeCell):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype.get formParameters):
+        (WebInspector.Resource.prototype.requestContentType):
+        (WebInspector.Resource.prototype.isPingRequest):
+        * loader/PingLoader.cpp:
+        (WebCore::PingLoader::PingLoader):
+        * loader/PingLoader.h:
+
 2011-04-28  Pavel Podivilov  <podivilov@chromium.org>
 
         Reviewed by Pavel Feldman.
index 747a462..314bec8 100644 (file)
Binary files a/Source/WebCore/English.lproj/localizedStrings.js and b/Source/WebCore/English.lproj/localizedStrings.js differ
index ec00c23..b02c137 100644 (file)
@@ -403,6 +403,11 @@ void InspectorInstrumentation::willSendRequestImpl(InspectorAgent* inspectorAgen
         resourceAgent->willSendRequest(identifier, loader, request, redirectResponse);
 }
 
+void InspectorInstrumentation::continueAfterPingLoaderImpl(InspectorAgent* inspectorAgent, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
+{
+    willSendRequestImpl(inspectorAgent, identifier, loader, request, response);
+}
+
 void InspectorInstrumentation::markResourceAsCachedImpl(InspectorAgent* inspectorAgent, unsigned long identifier)
 {
     if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(inspectorAgent))
index 94ec8bf..ca1be35 100644 (file)
@@ -113,6 +113,7 @@ public:
 
     static void applyUserAgentOverride(Frame*, String*);
     static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
+    static void continueAfterPingLoader(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
     static void markResourceAsCached(Page*, unsigned long identifier);
     static void didLoadResourceFromMemoryCache(Page*, DocumentLoader*, const CachedResource*);
     static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier);
@@ -234,6 +235,7 @@ private:
 
     static void applyUserAgentOverrideImpl(InspectorAgent*, String*);
     static void willSendRequestImpl(InspectorAgent*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
+    static void continueAfterPingLoaderImpl(InspectorAgent*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
     static void markResourceAsCachedImpl(InspectorAgent*, unsigned long identifier);
     static void didLoadResourceFromMemoryCacheImpl(InspectorAgent*, DocumentLoader*, const CachedResource*);
     static InspectorInstrumentationCookie willReceiveResourceDataImpl(InspectorAgent*, unsigned long identifier);
@@ -628,6 +630,14 @@ inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned lon
 #endif
 }
 
+inline void InspectorInstrumentation::continueAfterPingLoader(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorAgent* ic = inspectorAgentForFrame(frame))
+        InspectorInstrumentation::continueAfterPingLoaderImpl(ic, identifier, loader, request, response);
+#endif
+}
+
 inline void InspectorInstrumentation::markResourceAsCached(Page* page, unsigned long identifier)
 {
 #if ENABLE(INSPECTOR)
index 2d906f2..54113dc 100644 (file)
@@ -1488,15 +1488,7 @@ WebInspector.NetworkDataGridNode.prototype = {
         this._methodCell.setTextAndTitle(this._resource.requestMethod);
 
         this._refreshStatusCell();
-
-        if (this._resource.mimeType) {
-            this._typeCell.removeStyleClass("network-dim-cell");
-            this._typeCell.setTextAndTitle(this._resource.mimeType);
-        } else {
-            this._typeCell.addStyleClass("network-dim-cell");
-            this._typeCell.setTextAndTitle(WebInspector.UIString("Pending"));
-        }
-
+        this._refreshTypeCell();
         this._refreshSizeCell();
         this._refreshTimeCell();
 
@@ -1579,12 +1571,28 @@ WebInspector.NetworkDataGridNode.prototype = {
         } else {
             if (this._resource.isDataURL() && this._resource.finished)
                 this._statusCell.setTextAndTitle(WebInspector.UIString("(data url)"));
+            else if (this._resource.isPingRequest())
+                this._statusCell.setTextAndTitle(WebInspector.UIString("(ping)"));
             else
                 this._statusCell.setTextAndTitle(WebInspector.UIString("(Pending)"));
             this._statusCell.addStyleClass("network-dim-cell");
         }
     },
 
+    _refreshTypeCell: function()
+    {
+        if (this._resource.mimeType) {
+            this._typeCell.removeStyleClass("network-dim-cell");
+            this._typeCell.setTextAndTitle(this._resource.mimeType);
+        } else if (this._resource.isPingRequest) {
+            this._typeCell.removeStyleClass("network-dim-cell");
+            this._typeCell.setTextAndTitle(this._resource.requestContentType());
+        } else {
+            this._typeCell.addStyleClass("network-dim-cell");
+            this._typeCell.setTextAndTitle(WebInspector.UIString("Pending"));
+        }
+    },
+
     _refreshSizeCell: function()
     {
         var resourceSize = typeof this._resource.resourceSize === "number" ? Number.bytesToString(this._resource.resourceSize) : "?";
index c548d85..bf063e1 100644 (file)
@@ -587,7 +587,7 @@ WebInspector.Resource.prototype = {
             return this._parsedFormParameters;
         if (!this.requestFormData)
             return;
-        var requestContentType = this.requestHeaderValue("Content-Type");
+        var requestContentType = this.requestContentType();
         if (!requestContentType || !requestContentType.match(/^application\/x-www-form-urlencoded\s*(;.*)?$/i))
             return;
         this._parsedFormParameters = this._parseParameters(this.requestFormData);
@@ -847,6 +847,16 @@ WebInspector.Resource.prototype = {
         return this.url.match(/^data:/i);
     },
     
+    requestContentType: function()
+    {
+        return this.requestHeaderValue("Content-Type");
+    },
+
+    isPingRequest: function()
+    {
+        return "text/ping" === this.requestContentType();
+    },
+    
     _contentURL: function()
     {
         const maxDataUrlSize = 1024 * 1024;
index 71d9514..9745273 100644 (file)
@@ -36,6 +36,7 @@
 #include "FormData.h"
 #include "Frame.h"
 #include "FrameLoaderClient.h"
+#include "InspectorInstrumentation.h"
 #include "Page.h"
 #include "ProgressTracker.h"
 #include "ResourceHandle.h"
@@ -110,13 +111,15 @@ void PingLoader::reportContentSecurityPolicyViolation(Frame* frame, const KURL&
     UNUSED_PARAM(leakedPingLoader);
 }
 
-PingLoader::PingLoader(Frame* frame, const ResourceRequest& request)
+PingLoader::PingLoader(Frame* frame, ResourceRequest& request)
     : m_timeout(this, &PingLoader::timeout)
 {
     unsigned long identifier = frame->page()->progress()->createUniqueIdentifier();
     m_shouldUseCredentialStorage = frame->loader()->client()->shouldUseCredentialStorage(frame->loader()->activeDocumentLoader(), identifier);
     m_handle = ResourceHandle::create(frame->loader()->networkingContext(), request, this, false, false);
 
+    InspectorInstrumentation::continueAfterPingLoader(frame, identifier, frame->loader()->activeDocumentLoader(), request, ResourceResponse());
+
     // If the server never responds, FrameLoader won't be able to cancel this load and
     // we'll sit here waiting forever. Set a very generous timeout, just in case.
     m_timeout.startOneShot(60000);
index 413eb61..248e934 100644 (file)
@@ -61,7 +61,7 @@ public:
     ~PingLoader();
 
 private:
-    PingLoader(Frame*, const ResourceRequest&);
+    PingLoader(Frame*, ResourceRequest&);
 
     void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { delete this; }
     void didReceiveData(ResourceHandle*, const char*, int, int) { delete this; }