Bug 131252 - Web Inspector: JSContext inspection Resource search does not work
Summary: Web Inspector: JSContext inspection Resource search does not work
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-04-04 19:02 PDT by Joseph Pecoraro
Modified: 2014-12-04 13:00 PST (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (30.21 KB, patch)
2014-11-18 23:10 PST, Joseph Pecoraro
timothy: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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