Bug 35232

Summary: Web Inspector: Scripts panel shows blank source when stopping on a breakpoint on refresh.
Product: WebKit Reporter: Pavel Feldman <pfeldman>
Component: Web Inspector (Deprecated)Assignee: Pavel Feldman <pfeldman>
Severity: Normal CC: ap, bweinstein, joepeck, rik, timothy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
URL: http://testsuites.opera.com/JSON/correctness/004.html
Description Flags
[PATCH] Proposed fix. timothy: review+

Description Pavel Feldman 2010-02-22 03:19:06 PST
(Follow up to https://bugs.webkit.org/show_bug.cgi?id=28799)

I was thinking of a change that prevents scripts from being bound to resources prior to the resource's finished event and it works fine for secondary resources (external scripts). For main resource it would show multiple chunks of script tags first, and, once resource is loaded, it should replace chunks with the resource itself. Besides merging script entries upon resource finished event, there is a problem with chunks having 1-based lines numbering. It all breaks breakpoints.
Comment 1 Pavel Feldman 2010-02-22 03:21:12 PST
Steps to repro:
1. go to http://testsuites.opera.com/JSON/correctness/004.html
2. enable the debugger
3. set a breakpoint somewhere in the code of 004.js
4. reload the page

004.js is sometimes shown with empty content.
Comment 2 Pavel Feldman 2010-02-23 14:17:37 PST
Created attachment 49326 [details]
[PATCH] Proposed fix.
Comment 3 Timothy Hatcher 2010-02-23 17:45:26 PST
Comment on attachment 49326 [details]
[PATCH] Proposed fix.

> +        var prefix = [];
> +        for (var i = 0; i < this.script.startingLine; ++i)
> +            prefix.push("");
> +        
> +        this.sourceFrame.setContent("text/javascript", prefix.join("\n") + this.script.source);

Why not just build a string by appending "\n"? I think JSC optimizes that case.

> +            this._resourceForURLInFilesSelect[script.resource.url] = script.resource;
> +       }
> + 
> +        var displayName = script.sourceURL ? WebInspector.displayNameForURL(script.sourceURL) : WebInspector.UIString("(program)");

Bad indent on the } line.
Comment 4 Pavel Feldman 2010-02-25 05:45:45 PST
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	WebCore/ChangeLog
	M	WebCore/inspector/front-end/Panel.js
	M	WebCore/inspector/front-end/ResourcesPanel.js
	M	WebCore/inspector/front-end/Script.js
	M	WebCore/inspector/front-end/ScriptView.js
	M	WebCore/inspector/front-end/ScriptsPanel.js
	M	WebCore/inspector/front-end/SourceView.js
	M	WebCore/inspector/front-end/inspector.js
Committed r55231