Bug 154214

Summary: Web Inspector: XHRs and Web Worker scripts are not searchable
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, graouts, joepeck, keith_miller, mark.lam, mattbaker, msaboff, nvasilyev, saam, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Work In Progress
none
[PATCH] Proposed Fix none

Description Joseph Pecoraro 2016-02-13 04:46:31 PST
* SUMMARY
XHRs and Web Worker scripts are not searchable.

The resources show up in the sidebar, but they are not searchable.
Comment 1 Radar WebKit Bug Importer 2016-02-13 04:46:45 PST
<rdar://problem/24643587>
Comment 2 Joseph Pecoraro 2016-02-13 04:53:09 PST
Created attachment 271282 [details]
[PATCH] Work In Progress

I'm a bit skeptical of this patch at the moment, but I'm putting it up for feedback.

It seems Page.searchInResources only walks the CachedResources that are still around for frames/documents. Unfortunately XHR resources, and other "Raw Resources" (Worker script) are not included in this list. The NetworkAgent is told about these Raw CachedResources before they are destroyed, and was saving their data in the NetworkResourcesData class off of the NetworkAgent. So we could ask the NetworkAgent to search its "Other Resources", which I just called "searchRequests" here... But this seems to capture all the resources NOT searched by PageAgent.

This lets us search in a near identical way to searching Page resources.

  Page.searchInResources
    => Page.searchInResource(frameId, url)
      => frameId, url, match info => UI

  Network.searchInRequests
    => Network.searchRequest(requestId) (frameId is known)
      => frameId, url, match info => UI

I'm guessing NetworkResourcesData was actually used for a different purpose (XHR Replay?) but we can take advantage of it here for searching XHRs.

The one caveat is, like all things NetworkAgent related, the inspector has to be open to capture the content of XHRs. You can't search XHRs that happened before the inspector was opened. I think that is fine / to be expected. The same way scripts get garbage collected, resources do as well.
Comment 3 Timothy Hatcher 2016-02-13 05:26:25 PST
Comment on attachment 271282 [details]
[PATCH] Work In Progress

Looks good.
Comment 4 Joseph Pecoraro 2016-02-13 17:36:03 PST
Thought about this a bit. Really, Page.searchInResources should just be doing this.

On the backend, PageAgent can can shimmy on over to the NetworkAgent for the data it needs, but it doesn't seem useful to add Network agent protocol methods for this.
Comment 5 Timothy Hatcher 2016-02-15 12:07:52 PST
<rdar://problem/16660513>
Comment 6 Joseph Pecoraro 2016-04-08 16:56:27 PDT
Created attachment 276056 [details]
[PATCH] Proposed Fix
Comment 7 WebKit Commit Bot 2016-04-08 19:37:18 PDT
Comment on attachment 276056 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 276056

Committed r199263: <http://trac.webkit.org/changeset/199263>
Comment 8 WebKit Commit Bot 2016-04-08 19:37:21 PDT
All reviewed patches have been landed.  Closing bug.