Bug 131252

Summary: Web Inspector: JSContext inspection Resource search does not work
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: burg, graouts, joepeck, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix timothy: review+

Description Joseph Pecoraro 2014-04-04 19:02:19 PDT
The Resource Panel's search bar in a JSContext Inspector currently does not work. It should!
Comment 1 Radar WebKit Bug Importer 2014-04-04 19:02:47 PDT
<rdar://problem/16531981>
Comment 2 Joseph Pecoraro 2014-11-18 23:01:11 PST
<rdar://problem/13776248>
Comment 3 Joseph Pecoraro 2014-11-18 23:01:47 PST
This also affects Extra Scripts, Anonymous Scripts, and Extension Scripts when inspecting a web page. I have a fix.
Comment 4 Joseph Pecoraro 2014-11-18 23:10:11 PST
Created attachment 241848 [details]
[PATCH] Proposed Fix
Comment 5 Timothy Hatcher 2014-11-19 09:48:33 PST
Comment on attachment 241848 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=241848&action=review

> Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js:422
> +                    var lineMatch;
> +                    var searchRegex = new RegExp(searchTerm.escapeForRegExp(), "gi");
> +                    while ((searchRegex.lastIndex < match.lineContent.length) && (lineMatch = searchRegex.exec(match.lineContent))) {
> +                        var matchObject = new WebInspector.SourceCodeSearchMatchObject(script, match.lineContent, searchTerm, new WebInspector.TextRange(match.lineNumber, lineMatch.index, match.lineNumber, searchRegex.lastIndex));
> +                        var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
> +                        scriptTreeElement.appendChild(matchTreeElement);
>                      }

We should make this a helper that returns an array of matches or calls a function for each match. We have written this about 3-4 times in out codebase.

> Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js:737
> +            var children = folderTreeElement.children;
> +            for (var treeElement of children) {
> +                if (treeElement instanceof WebInspector.ScriptTreeElement)
> +                    nonResourceScripts.push(treeElement.script);
> +            }

Assert that there are no sub-folders or any tree elements that have children that might need searched?

> Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js:742
> +        if (WebInspector.debuggableType === WebInspector.DebuggableType.JavaScript && !WebInspector.hasExtraDomains)
> +            collectFromTreeElement(this._resourcesContentTreeOutline);
> +        else {

I hate no braces in this case, but it is our style...
Comment 6 Joseph Pecoraro 2014-11-19 15:50:33 PST
http://trac.webkit.org/changeset/176358