Changeset 70762 in webkit


Ignore:
Timestamp:
Oct 28, 2010 3:22:51 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2010-10-27 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: make debugger work against new resource manager.
https://bugs.webkit.org/show_bug.cgi?id=48376

  • inspector/Inspector.idl:
  • inspector/InspectorController.cpp: (WebCore::InspectorController::identifierForInitialRequest):
  • inspector/InspectorResourceAgent.cpp: (WebCore::InspectorResourceAgent::identifierForInitialRequest):
  • inspector/InspectorResourceAgent.h:
  • inspector/front-end/ExtensionServer.js: (WebInspector.ExtensionServer.prototype._onGetResourceContent):
  • inspector/front-end/Resource.js: (WebInspector.Resource.prototype.set content):
  • inspector/front-end/ResourceManager.js: (WebInspector.ResourceManager): (WebInspector.ResourceManager.prototype.identifierForInitialRequest): (WebInspector.ResourceManager.prototype._createResource): (WebInspector.ResourceManager.prototype.willSendRequest): (WebInspector.ResourceManager.prototype._updateResourceWithRequest): (WebInspector.ResourceManager.prototype.didFinishLoading): (WebInspector.ResourceManager.prototype.didFailLoading): (WebInspector.ResourceManager.prototype.setOverrideContent): (WebInspector.ResourceManager.prototype._processCachedResources): (WebInspector.ResourceManager.prototype._addFramesRecursively): (WebInspector.ResourceManager.prototype.resourceForURL): (WebInspector.ResourceManager.prototype.addConsoleMessage): (WebInspector.ResourceManager.prototype.clearConsoleMessages): (WebInspector.ResourceManager.prototype.forAllResources): (WebInspector.ResourceManager.prototype._bindResourceURL): (WebInspector.ResourceManager.prototype._unbindResourceURL): (WebInspector.ResourceManager.getContent): (WebInspector.ResourceTreeModel): (WebInspector.ResourceTreeModel.prototype.didCommitLoadForFrame): (WebInspector.ResourceTreeModel.prototype.addResourceToFrame): (WebInspector.ResourceTreeModel.prototype._clearResources):
  • inspector/front-end/StoragePanel.js: (WebInspector.StoragePanel.prototype.addOrUpdateFrame):
  • inspector/front-end/networkPanel.css: (.network.panel .resources-dividers):

2010-10-27 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: make debugger work against new resource manager.
https://bugs.webkit.org/show_bug.cgi?id=48376

  • http/tests/inspector/inspector-test2.js: (initialize_InspectorTest.InspectorTest.reloadPageIfNeeded): (initialize_InspectorTest.InspectorTest.pageReloaded):
  • http/tests/inspector/resource-har-conversion.html:
  • http/tests/inspector/resource-parameters.html:
  • inspector/extensions-resources.html:
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70755 r70762  
     12010-10-27  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: make debugger work against new resource manager.
     6        https://bugs.webkit.org/show_bug.cgi?id=48376
     7
     8        * http/tests/inspector/inspector-test2.js:
     9        (initialize_InspectorTest.InspectorTest.reloadPageIfNeeded):
     10        (initialize_InspectorTest.InspectorTest.pageReloaded):
     11        * http/tests/inspector/resource-har-conversion.html:
     12        * http/tests/inspector/resource-parameters.html:
     13        * inspector/extensions-resources.html:
     14
    1152010-10-28  Adam Barth  <abarth@webkit.org>
    216
  • trunk/LayoutTests/http/tests/inspector/inspector-test2.js

    r70682 r70762  
    8585InspectorTest.reloadPageIfNeeded = function(callback)
    8686{
    87     if (!InspectorTest._pageWasReloaded)
     87    if (!InspectorTest._pageWasReloaded) {
     88        InspectorTest._pageWasReloaded = true;
    8889        InspectorTest.reloadPage(callback);
    89     else
     90    } else
    9091        callback();
    9192}
     
    9394InspectorTest.pageReloaded = function()
    9495{
    95     InspectorTest._pageWasReloaded = true;
    9696    resultsSynchronized = false;
    9797    InspectorTest.addResult("Page reloaded.");
  • trunk/LayoutTests/http/tests/inspector/resource-har-conversion.html

    r70137 r70762  
    1010    function getHAR(id)
    1111    {
    12         return new WebInspector.HAREntry(WebInspector.resources[id]).build();
     12        return new WebInspector.HAREntry(WebInspector.networkResources[id]).build();
    1313    }
    1414
     
    2525    function findResourceByURL(url)
    2626    {
    27         for (var resource in WebInspector.resources) {
    28             if (url.test(WebInspector.resources[resource].url))
    29                 return WebInspector.resources[resource];
     27        for (var id in WebInspector.networkResources) {
     28            if (url.test(WebInspector.networkResources[id].url))
     29                return WebInspector.networkResources[id];
    3030        }
    3131    }
     
    3434        InjectedScriptAccess.getDefault().evaluate("doXHR()", "console", function() {
    3535            addCookieHeadersToResource(findResourceByURL(/inspector-test2\.js$/));
    36             var resources = Object.keys(WebInspector.resources).map(getHAR).sort(InspectorTest.resourceURLComparer);
     36            var resources = Object.keys(WebInspector.networkResources).map(getHAR).sort(InspectorTest.resourceURLComparer);
    3737            InspectorTest.addObject(resources, InspectorTest.HARNondeterministicPropertiesWithSize);
    3838            InspectorTest.disableResourceTracking();
  • trunk/LayoutTests/http/tests/inspector/resource-parameters.html

    r70682 r70762  
    3333function frontend_enableResourceTracking(testController)
    3434{
    35     if (!WebInspector.panels.resources.resourceTrackingEnabled) {
     35    if (Preferences.networkPanelEnabled) {
     36        if (!WebInspector.panels.network._pageWasReloaded) {
     37            WebInspector.panels.network._pageWasReloaded = true;
     38            WebInspector.panels.network._reset();
     39            InspectorBackend.reloadPage();
     40            return "enabling";
     41        }
     42    } else if (!WebInspector.panels.resources.resourceTrackingEnabled) {
    3643        WebInspector.panels.resources.toggleResourceTracking();
    3744        return "enabling";
     
    4451    var resource = WebInspector.resourceForURL("http://localhost:8000/inspector/resources/post-target.cgi?queryParam1=queryValue1&queryParam2=");
    4552
    46     WebInspector.panels.resources.toggleResourceTracking();
     53    if (!Preferences.networkPanelEnabled)
     54        WebInspector.panels.resources.toggleResourceTracking();
    4755
    4856    if (!resource) {
  • trunk/LayoutTests/inspector/extensions-resources.html

    r69185 r70762  
    5656{
    5757    var xhr = new XMLHttpRequest();
    58     xhr.open('GET', location.href, false);
     58    xhr.open("GET", location.href, false);
    5959    xhr.send(null);
    6060}
  • trunk/WebCore/ChangeLog

    r70759 r70762  
     12010-10-27  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: make debugger work against new resource manager.
     6        https://bugs.webkit.org/show_bug.cgi?id=48376
     7
     8        * inspector/Inspector.idl:
     9        * inspector/InspectorController.cpp:
     10        (WebCore::InspectorController::identifierForInitialRequest):
     11        * inspector/InspectorResourceAgent.cpp:
     12        (WebCore::InspectorResourceAgent::identifierForInitialRequest):
     13        * inspector/InspectorResourceAgent.h:
     14        * inspector/front-end/ExtensionServer.js:
     15        (WebInspector.ExtensionServer.prototype._onGetResourceContent):
     16        * inspector/front-end/Resource.js:
     17        (WebInspector.Resource.prototype.set content):
     18        * inspector/front-end/ResourceManager.js:
     19        (WebInspector.ResourceManager):
     20        (WebInspector.ResourceManager.prototype.identifierForInitialRequest):
     21        (WebInspector.ResourceManager.prototype._createResource):
     22        (WebInspector.ResourceManager.prototype.willSendRequest):
     23        (WebInspector.ResourceManager.prototype._updateResourceWithRequest):
     24        (WebInspector.ResourceManager.prototype.didFinishLoading):
     25        (WebInspector.ResourceManager.prototype.didFailLoading):
     26        (WebInspector.ResourceManager.prototype.setOverrideContent):
     27        (WebInspector.ResourceManager.prototype._processCachedResources):
     28        (WebInspector.ResourceManager.prototype._addFramesRecursively):
     29        (WebInspector.ResourceManager.prototype.resourceForURL):
     30        (WebInspector.ResourceManager.prototype.addConsoleMessage):
     31        (WebInspector.ResourceManager.prototype.clearConsoleMessages):
     32        (WebInspector.ResourceManager.prototype.forAllResources):
     33        (WebInspector.ResourceManager.prototype._bindResourceURL):
     34        (WebInspector.ResourceManager.prototype._unbindResourceURL):
     35        (WebInspector.ResourceManager.getContent):
     36        (WebInspector.ResourceTreeModel):
     37        (WebInspector.ResourceTreeModel.prototype.didCommitLoadForFrame):
     38        (WebInspector.ResourceTreeModel.prototype.addResourceToFrame):
     39        (WebInspector.ResourceTreeModel.prototype._clearResources):
     40        * inspector/front-end/StoragePanel.js:
     41        (WebInspector.StoragePanel.prototype.addOrUpdateFrame):
     42        * inspector/front-end/networkPanel.css:
     43        (.network.panel .resources-dividers):
     44
    1452010-10-28  Andy Estes  <aestes@apple.com>
    246
  • trunk/WebCore/inspector/Inspector.idl

    r70622 r70762  
    111111        [handler=Resource] void cachedResources(out Object resources);
    112112        [handler=Resource] void resourceContent(in unsigned long frameId, in String url, in boolean base64Encode, out String content);
    113         [notify] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out boolean isMainResource);
     113        [notify] void identifierForInitialRequest(out long identifier, out String url, out Object loader);
    114114        [notify] void willSendRequest(out long identifier, out double time, out Object request, out Object redirectResponse);
    115115        [notify] void markResourceAsCached(out long identifier);
  • trunk/WebCore/inspector/InspectorController.cpp

    r70622 r70762  
    921921    ASSERT(m_inspectedPage);
    922922
     923    if (m_resourceAgent)
     924        m_resourceAgent->identifierForInitialRequest(identifier, request.url(), loader);
     925
    923926    bool isMainResource = isMainResourceLoader(loader, request.url());
    924 
    925     if (m_resourceAgent)
    926         m_resourceAgent->identifierForInitialRequest(identifier, request.url(), loader, isMainResource);
    927927
    928928    ensureSettingsLoaded();
  • trunk/WebCore/inspector/InspectorResourceAgent.cpp

    r70519 r70762  
    275275}
    276276
    277 void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifier, const KURL& url, DocumentLoader* loader, bool isMainResource)
     277void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifier, const KURL& url, DocumentLoader* loader)
    278278{
    279279    RefPtr<InspectorObject> loaderObject = buildObjectForDocumentLoader(loader);
    280     m_frontend->identifierForInitialRequest(identifier, url.string(), loaderObject, isMainResource);
     280    m_frontend->identifierForInitialRequest(identifier, url.string(), loaderObject);
    281281}
    282282
  • trunk/WebCore/inspector/InspectorResourceAgent.h

    r70519 r70762  
    7878    ~InspectorResourceAgent();
    7979
    80     void identifierForInitialRequest(unsigned long identifier, const KURL&, DocumentLoader*, bool isMainResource);
     80    void identifierForInitialRequest(unsigned long identifier, const KURL&, DocumentLoader*);
    8181    void willSendRequest(unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
    8282    void markResourceAsCached(unsigned long identifier);
  • trunk/WebCore/inspector/front-end/ExtensionServer.js

    r70532 r70762  
    300300            var id = ids[i];
    301301            var resource = WebInspector.networkResources[id];
     302 
    302303            if (!resource)
    303304                response.push(this._status.E_NOTFOUND(id));
  • trunk/WebCore/inspector/front-end/Resource.js

    r70532 r70762  
    601601    },
    602602
     603    set content(content)
     604    {
     605        this._content = content;
     606    },
     607
    603608    getContent: function(callback)
    604609    {
  • trunk/WebCore/inspector/front-end/ResourceManager.js

    r70535 r70762  
    4949
    5050    this._resourcesById = {};
     51    this._resourcesByURL = {};
    5152    this._resourceTreeModel = new WebInspector.ResourceTreeModel();
    5253    InspectorBackend.cachedResources(this._processCachedResources.bind(this));
     
    6061    },
    6162
    62     identifierForInitialRequest: function(identifier, url, loader, isMainResource)
     63    identifierForInitialRequest: function(identifier, url, loader)
    6364    {
    6465        var resource = this._createResource(identifier, url, loader);
    65         if (isMainResource) {
     66        if (loader.url === url) {
    6667            resource.isMainResource = true;
    6768            WebInspector.mainResource = resource;
    6869        }
    6970
     71        // It is important to bind resource url early (before scripts compile).
     72        this._bindResourceURL(resource);
     73
    7074        WebInspector.panels.network.addResource(resource);
    7175        WebInspector.panels.audits.resourceStarted(resource);
     
    7680        var resource = new WebInspector.Resource(identifier, url);
    7781        resource.loader = loader;
     82        resource.documentURL = loader.url;
    7883
    7984        this._resourcesById[identifier] = resource;
     
    96101        }
    97102
    98         resource.requestMethod = request.httpMethod;
    99         resource.requestHeaders = request.httpHeaderFields;
    100         resource.requestFormData = request.requestFormData;
     103        this._updateResourceWithRequest(resource, request);
    101104        resource.startTime = time;
    102105
     
    106109        } else
    107110            WebInspector.panels.network.refreshResource(resource);
     111    },
     112
     113    _updateResourceWithRequest: function(resource, request)
     114    {
     115        resource.requestMethod = request.httpMethod;
     116        resource.requestHeaders = request.httpHeaderFields;
     117        resource.requestFormData = request.requestFormData;
    108118    },
    109119
     
    190200        WebInspector.panels.network.refreshResource(resource);
    191201        WebInspector.panels.audits.resourceFinished(resource);
     202        WebInspector.extensionServer.notifyResourceFinished(resource);
    192203        delete this._resourcesById[identifier];
    193204    },
     
    200211
    201212        resource.failed = true;
     213        resource.finished = true;
    202214        resource.endTime = time;
    203215
    204216        WebInspector.panels.network.refreshResource(resource);
    205217        WebInspector.panels.audits.resourceFinished(resource);
     218        WebInspector.extensionServer.notifyResourceFinished(resource);
    206219        delete this._resourcesById[identifier];
    207220    },
     
    229242    setOverrideContent: function(identifier, sourceString, type)
    230243    {
    231         var resource = this._resourcesById[identifier];
     244        var resource = WebInspector.panels.network.resources[identifier];
    232245        if (!resource)
    233246            return;
    234247
    235248        resource.type = WebInspector.Resource.Type[type];
    236         resource.overridenContent = sourceString;
    237 
     249        resource.content = sourceString;
    238250        WebInspector.panels.network.refreshResource(resource);
    239251    },
     
    299311    _processCachedResources: function(mainFramePayload)
    300312    {
    301         this._addFramesRecursively(null, mainFramePayload);
     313        var mainResource = this._addFramesRecursively(null, mainFramePayload);
     314        WebInspector.mainResource = mainResource;
     315        mainResource.isMainResource = true;
    302316    },
    303317
     
    305319    {
    306320        var frameResource = this._createResource(null, framePayload.resource.url, framePayload.resource.loader);
     321        this._updateResourceWithRequest(frameResource, framePayload.resource.request);
     322        this._updateResourceWithResponse(frameResource, framePayload.resource.response);
    307323        frameResource.type = WebInspector.Resource.Type["Document"];
     324        frameResource.finished = true;
     325        this._bindResourceURL(frameResource);
     326
    308327        this._resourceTreeModel.addOrUpdateFrame(parentFrameId, framePayload.id, frameResource.displayName);
    309328        this._resourceTreeModel.addResourceToFrame(framePayload.id, frameResource);
     
    320339            this._updateResourceWithCachedResource(resource, cachedResource);
    321340            resource.finished = true;
     341            this._bindResourceURL(resource);
    322342            this._resourceTreeModel.addResourceToFrame(framePayload.id, resource);
    323343        }
     344        return frameResource;
    324345    },
    325346
    326347    resourceForURL: function(url)
    327348    {
    328         return this._resourceTreeModel.resourceForURL(url);
     349        // FIXME: receive frameId here.
     350        var entry = this._resourcesByURL[url];
     351        if (entry instanceof Array)
     352            return entry[0];
     353        return entry;
    329354    },
    330355
    331356    addConsoleMessage: function(msg)
    332357    {
    333         var resource = this._resourceTreeModel.resourceForURL(msg.url);
     358        var resource = this.resourceForURL(msg.url);
    334359        if (!resource)
    335360            return;
     
    356381        }
    357382        this._resourceTreeModel.forAllResources(callback);
     383    },
     384
     385    forAllResources: function(callback)
     386    {
     387        this._resourceTreeModel.forAllResources(callback);
     388    },
     389
     390    _bindResourceURL: function(resource)
     391    {
     392        var resourceForURL = this._resourcesByURL[resource.url];
     393        if (!resourceForURL)
     394            this._resourcesByURL[resource.url] = resource;
     395        else if (resourceForURL instanceof Array)
     396            resourceForURL.push(resource);
     397        else
     398            this._resourcesByURL[resource.url] = [resourceForURL];
     399    },
     400
     401    _unbindResourceURL: function(resource)
     402    {
     403        var resourceForURL = this._resourcesByURL[resource.url];
     404        if (!resourceForURL)
     405            return;
     406
     407        if (resourceForURL instanceof Array) {
     408            resourceForURL.remove(resource, true);
     409            if (resourceForURL.length === 1)
     410                this._resourcesByURL[resource.url] = resourceForURL[0];
     411            return;
     412        }
     413
     414        delete this._resourcesByURL[resource.url];
    358415    }
    359416}
     
    411468WebInspector.ResourceManager.getContent = function(resource, base64Encode, callback)
    412469{
    413     if ("overridenContent" in resource) {
    414         callback(resource.overridenContent);
    415         return;
    416     }
    417 
    418470    // FIXME: eventually, cached resources will have no identifiers.
    419471    if (resource.loader)
     
    427479    this._resourcesByFrameId = {};
    428480    this._subframes = {};
    429     this._resourcesByURL = {};
    430481}
    431482
     
    450501
    451502        var resourcesForFrame = this._resourcesByFrameId[loader.frameId];
    452         for (var i = 0; resourcesForFrame && i < resourcesForFrame.length; ++i)
     503        for (var i = 0; resourcesForFrame && i < resourcesForFrame.length; ++i) {
     504            WebInspector.resourceManager._bindResourceURL(resourcesForFrame[i]);
    453505            WebInspector.panels.storage.addResourceToFrame(loader.frameId, resourcesForFrame[i]);
     506        }
    454507    },
    455508
     
    484537        }
    485538        resourcesForFrame.push(resource);
    486         this._bindResourceURL(resource);
    487539
    488540        WebInspector.panels.storage.addResourceToFrame(frameId, resource);
     
    502554                continue;
    503555            }
    504             this._unbindResourceURL(resource);
     556            WebInspector.resourceManager._unbindResourceURL(resource);
    505557        }
    506558
     
    508560        if (preservedResourcesForFrame.length)
    509561            this._resourcesByFrameId[frameId] = preservedResourcesForFrame;
    510     },
    511 
    512     _bindResourceURL: function(resource)
    513     {
    514         var resourceForURL = this._resourcesByURL[resource.url];
    515         if (!resourceForURL)
    516             this._resourcesByURL[resource.url] = resource;
    517         else if (resourceForURL instanceof Array)
    518             resourceForURL.push(resource);
    519         else
    520             this._resourcesByURL[resource.url] = [ resourceForURL ];
    521     },
    522 
    523     _unbindResourceURL: function(resource)
    524     {
    525         var resourceForURL = this._resourcesByURL[resource.url];
    526         if (!resourceForURL)
    527             return;
    528 
    529         if (resourceForURL instanceof Array) {
    530             resourceForURL.remove(resource, true);
    531             if (resourceForURL.length === 1)
    532                 this._resourcesByURL[resource.url] = resourceForURL[0];
    533             return;
    534         }
    535 
    536         delete this._resourcesByURL[resource.url];
    537     },
    538 
    539     resourceForURL: function(url)
    540     {
    541         // FIXME: receive frameId here.
    542         var entry = this._resourcesByURL[url];
    543         if (entry instanceof Array)
    544             return entry[0];
    545         return entry;
    546562    },
    547563
  • trunk/WebCore/inspector/front-end/StoragePanel.js

    r70454 r70762  
    131131        var parentTreeElement = parentFrameId ? this._treeElementForFrameId[parentFrameId] : this.resourcesListTreeElement;
    132132        if (!parentTreeElement) {
    133             console.error("No frame with id:" + parentFrameId + " to route " + displayName + " to.")
     133            console.warning("No frame with id:" + parentFrameId + " to route " + displayName + " to.")
    134134            return;
    135135        }
  • trunk/WebCore/inspector/front-end/networkPanel.css

    r70420 r70762  
    420420}
    421421
     422.network.panel .resources-dividers {
     423    z-index: 0;
     424}
     425
    422426.network.panel .resources-dividers-label-bar {
    423427    background-color: transparent;
Note: See TracChangeset for help on using the changeset viewer.