2011-03-04 Andrey Kosyakov <caseq@chromium.org>
authorcaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Mar 2011 16:37:26 +0000 (16:37 +0000)
committercaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Mar 2011 16:37:26 +0000 (16:37 +0000)
        Reviewed by Pavel Feldman.

        Use internal ids for resources in extension server.
        Log errors in inspector tests.

        Web Inspector: [Extensions API] maintain own, unique & persistent identifiers for resources
        https://bugs.webkit.org/show_bug.cgi?id=55686

        * http/tests/inspector/inspector-test.js:
        (initialize_InspectorTest.consoleOutputHook):
2011-03-04  Andrey Kosyakov  <caseq@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: [Extensions API] maintain own, unique & persistent identifiers for resources.
        https://bugs.webkit.org/show_bug.cgi?id=55686

        - Use internal ids for resources in extension server.
        - Log errors in inspector tests.

        * inspector/front-end/ExtensionServer.js:
        (WebInspector.ExtensionServer):
        (WebInspector.ExtensionServer.prototype.resetResources):
        (WebInspector.ExtensionServer.prototype._notifyResourceFinished):
        (WebInspector.ExtensionServer.prototype._onRevealAndSelectResource):
        (WebInspector.ExtensionServer.prototype._onGetHAR):
        (WebInspector.ExtensionServer.prototype._onGetResourceContent):
        (WebInspector.ExtensionServer.prototype._resourceId):
        (WebInspector.ExtensionServer.prototype._resourceById):
        * inspector/front-end/HAREntry.js:
        (WebInspector.HARLog):
        (WebInspector.HARLog.prototype._convertResource):
        * inspector/front-end/NetworkPanel.js:
        (WebInspector.NetworkPanel.prototype._reset):

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/extensions-resources-redirect-expected.txt
LayoutTests/http/tests/inspector/inspector-test.js
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/ExtensionServer.js
Source/WebCore/inspector/front-end/HAREntry.js
Source/WebCore/inspector/front-end/NetworkPanel.js

index 5d6c5ec..620e015 100644 (file)
@@ -1,3 +1,16 @@
+2011-03-04  Andrey Kosyakov  <caseq@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Use internal ids for resources in extension server.
+        Log errors in inspector tests.
+
+        Web Inspector: [Extensions API] maintain own, unique & persistent identifiers for resources
+        https://bugs.webkit.org/show_bug.cgi?id=55686
+
+        * http/tests/inspector/inspector-test.js:
+        (initialize_InspectorTest.consoleOutputHook):
+
 2011-03-04  Pavel Feldman  <pfeldman@chromium.org>
 
         Not reviewed: fix inspector test flake.
index 9a4e80e..ed41571 100644 (file)
@@ -4,7 +4,7 @@ Page reloaded.
 Started extension.
 Running tests...
 RUNNING TEST: extension_testGetRedirectResourceContent
-content: undefined, encoding: undefined
+content: null, encoding: base64
 RUNNING TEST: extension_testRedirectResourceFinished
 Finished resource: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?status=302
 Finished resource: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true
index dd8d192..da9d03e 100644 (file)
@@ -3,6 +3,16 @@ var initialize_InspectorTest = function() {
 var results = [];
 var resultsSynchronized = false;
 
+function consoleOutputHook(messageType)
+{
+    InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(arguments, 1));
+}
+
+console.log = consoleOutputHook.bind(InspectorTest, "log");
+console.error = consoleOutputHook.bind(InspectorTest, "error");
+console.warn = consoleOutputHook.bind(InspectorTest, "warn");
+console.info = consoleOutputHook.bind(InspectorTest, "info");
+
 InspectorTest.completeTest = function()
 {
     InspectorAgent.didEvaluateForTestInFrontend(InspectorTest.completeTestCallId, "");
index 43705ba..65c2278 100644 (file)
@@ -2,6 +2,31 @@
 
         Reviewed by Pavel Feldman.
 
+        Web Inspector: [Extensions API] maintain own, unique & persistent identifiers for resources.
+        https://bugs.webkit.org/show_bug.cgi?id=55686
+
+        - Use internal ids for resources in extension server.
+        - Log errors in inspector tests.
+
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer):
+        (WebInspector.ExtensionServer.prototype.resetResources):
+        (WebInspector.ExtensionServer.prototype._notifyResourceFinished):
+        (WebInspector.ExtensionServer.prototype._onRevealAndSelectResource):
+        (WebInspector.ExtensionServer.prototype._onGetHAR):
+        (WebInspector.ExtensionServer.prototype._onGetResourceContent):
+        (WebInspector.ExtensionServer.prototype._resourceId):
+        (WebInspector.ExtensionServer.prototype._resourceById):
+        * inspector/front-end/HAREntry.js:
+        (WebInspector.HARLog):
+        (WebInspector.HARLog.prototype._convertResource):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel.prototype._reset):
+
+2011-03-04  Andrey Kosyakov  <caseq@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
         Web Inspector: exceptions when building context menu in network panel
         https://bugs.webkit.org/show_bug.cgi?id=55678
 
index 803d958..f9af7dc 100644 (file)
@@ -34,6 +34,8 @@ WebInspector.ExtensionServer = function()
     this._handlers = {};
     this._subscribers = {};
     this._extraHeaders = {};
+    this._resources = {};
+    this._lastResourceId = 0;
     this._status = new WebInspector.ExtensionStatus();
 
     this._registerHandler("addRequestHeaders", this._onAddRequestHeaders.bind(this));
@@ -108,10 +110,15 @@ WebInspector.ExtensionServer.prototype = {
         delete this._clientObjects[auditRun.id];
     },
 
+    resetResources: function()
+    {
+        this._resources = {};
+    },
+
     _notifyResourceFinished: function(event)
     {
         var resource = event.data;
-        this._postNotification("resource-finished", resource.identifier, (new WebInspector.HAREntry(resource)).build());
+        this._postNotification("resource-finished", this._resourceId(resource), (new WebInspector.HAREntry(resource)).build());
     },
 
     _postNotification: function(type, details)
@@ -288,7 +295,7 @@ WebInspector.ExtensionServer.prototype = {
         var id = message.id;
         var resource = null;
 
-        resource = WebInspector.networkResourceById(id) || WebInspector.resourceForURL(id);
+        resource = this._resourceById(id) || WebInspector.resourceForURL(id);
         if (!resource)
             return this._status.E_NOTFOUND(typeof id + ": " + id);
 
@@ -303,9 +310,10 @@ WebInspector.ExtensionServer.prototype = {
 
     _onGetHAR: function(request)
     {
-        var harLog = new WebInspector.HARLog();
-        harLog.includeResourceIds = true;
-        return harLog.build();
+        var harLog = (new WebInspector.HARLog()).build();
+        for (var i = 0; i < harLog.entries.length; ++i)
+            harLog.entries[i]._resourceId = this._resourceId(WebInspector.networkResources[i]);
+        return harLog;
     },
 
     _onGetResourceContent: function(message, port)
@@ -318,12 +326,26 @@ WebInspector.ExtensionServer.prototype = {
             };
             this._dispatchCallback(message.requestId, port, response);
         }
-        var resource = WebInspector.networkResourceById(message.id);
+        var resource = this._resourceById(message.id);
         if (!resource)
             return this._status.E_NOTFOUND(message.id);
         resource.requestContent(onContentAvailable.bind(this));
     },
 
+    _resourceId: function(resource)
+    {
+        if (!resource._extensionResourceId) {
+            resource._extensionResourceId = ++this._lastResourceId;
+            this._resources[resource._extensionResourceId] = resource;
+        }
+        return resource._extensionResourceId;
+    },
+
+    _resourceById: function(id)
+    {
+        return this._resources[id];
+    },
+
     _onAddAuditCategory: function(request)
     {
         var category = new WebInspector.ExtensionAuditCategory(request.id, request.displayName, request.resultCount);
index 4d690b3..b5223b6 100644 (file)
@@ -189,7 +189,6 @@ WebInspector.HAREntry._toMilliseconds = function(time)
 
 WebInspector.HARLog = function()
 {
-    this.includeResourceIds = false;
 }
 
 WebInspector.HARLog.prototype = {
@@ -230,10 +229,7 @@ WebInspector.HARLog.prototype = {
 
     _convertResource: function(resource)
     {
-        var entry = (new WebInspector.HAREntry(resource)).build();
-        if (this.includeResourceIds)
-            entry._resourceId = resource.identifier;
-        return entry;
+        return (new WebInspector.HAREntry(resource)).build();
     },
 
     _pageEventTime: function(time)
index a48803a..06983f0 100644 (file)
@@ -732,6 +732,7 @@ WebInspector.NetworkPanel.prototype = {
         this._viewsContainerElement.removeChildren();
         this._viewsContainerElement.appendChild(this._closeButtonElement);
         this._updateSummaryBar();
+        WebInspector.extensionServer.resetResources();
     },
 
     get resources()