Bug 123231 - Web Inspector: Breakpoints in sourceURL named scripts do not work
Summary: Web Inspector: Breakpoints in sourceURL named scripts do 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: 2013-10-23 16:20 PDT by Joseph Pecoraro
Modified: 2013-10-24 11:20 PDT (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (8.83 KB, patch)
2013-10-24 10:42 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2013-10-23 16:20:54 PDT
SUMMARY:
Breakpoints in "//# sourceURL=foo" named scripts do not work.

TEST CASE:

    <button id="button">Click to Run foo()</button>
    <script>
    eval("function foo() {\n    debugger;\n    var a = 1;\n    var b = 2;\n    var c = a+b;\n    alert(c);\n}\n//# sourceURL=test.js")
    document.getElementById('button').addEventListener("click", function() {
        foo();
    });
    </script>

STEPS TO REPRODUCE:
1. Inspect test page.
2. Click button on inspected page. (Debugger pauses on debugger statement.
3. Set a breakpoint before the alert() statement
4. Click continue in the debugger
  => expected to hit the breakpoint, instead the alert happened
Comment 1 Radar WebKit Bug Importer 2013-10-23 16:21:01 PDT
<rdar://problem/15304492>
Comment 2 Joseph Pecoraro 2013-10-23 17:21:55 PDT
So InspectorDebuggerAgent::didParseSource keep track of all loaded Scripts. Unfortunately when setting breakpoints by URL, we check Script.url, and the "sourceURL" is lost at this point. We should save the sourceURL somewhere; on the script would be great!
Comment 3 Joseph Pecoraro 2013-10-23 18:19:33 PDT
I have a fix, I just need to write up a test for it.
Comment 4 Joseph Pecoraro 2013-10-24 10:42:52 PDT
Created attachment 215081 [details]
[PATCH] Proposed Fix
Comment 5 Timothy Hatcher 2013-10-24 10:51:19 PDT
Comment on attachment 215081 [details]
[PATCH] Proposed Fix

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

> Source/WebCore/inspector/InspectorDebuggerAgent.cpp:714
> +    String scriptURL = hasSourceURL ? script.sourceURL : script.url;

I wonder if we should just have one property — script.url — for the URL. Are both useful? Are other places that need to do something similar?
Comment 6 Joseph Pecoraro 2013-10-24 10:55:35 PDT
(In reply to comment #5)
> (From update of attachment 215081 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=215081&action=review
> 
> > Source/WebCore/inspector/InspectorDebuggerAgent.cpp:714
> > +    String scriptURL = hasSourceURL ? script.sourceURL : script.url;
> 
> I wonder if we should just have one property — script.url — for the URL. Are both useful? Are other places that need to do something similar?

I like the idea of having both around. I think ideally both the original URL and sourceURL could be sent to the frontend.
Comment 7 WebKit Commit Bot 2013-10-24 11:20:39 PDT
Comment on attachment 215081 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 215081

Committed r157939: <http://trac.webkit.org/changeset/157939>
Comment 8 WebKit Commit Bot 2013-10-24 11:20:41 PDT
All reviewed patches have been landed.  Closing bug.