Bug 116292

Summary: Web Inspector: SyntaxError evaluating "1+1; //@ sourceURL=test" in console
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web Inspector (Deprecated)Assignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, 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+
[PATCH] Updated Patch none

Description Joseph Pecoraro 2013-05-16 23:02:54 PDT
Looks like the "with() { <expr> }" evaluation path needs to allow a newline after the user provided expression. If it ends in a single line comment it would comment out the closing brace for the with block! This is a Regression for sure. Easy fix.
Comment 1 Radar WebKit Bug Importer 2013-05-16 23:03:11 PDT
<rdar://problem/13920910>
Comment 2 Joseph Pecoraro 2013-05-16 23:23:56 PDT
Test Before:

    // test
    SyntaxError: Expected token '}'

Test After:

    // test
    undefined

I think it is cleaner to have a newline before and after the expression. Especially if you add a sourceURL or debugger statement. That does mean exceptions / errors might be off by 1 in their stack trace. But we should do a better job there anyways.
Comment 3 Radar WebKit Bug Importer 2013-05-16 23:24:29 PDT
<rdar://problem/13921036>
Comment 4 Joseph Pecoraro 2013-05-16 23:26:59 PDT
Created attachment 202048 [details]
[PATCH] Proposed Fix
Comment 5 Timothy Hatcher 2013-05-17 05:01:13 PDT
Comment on attachment 202048 [details]
[PATCH] Proposed Fix

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

> Source/WebCore/inspector/InjectedScriptSource.js:600
> +                expression = "with ((window && window.console && window.console.__commandLineAPI) || {}) {\n" + expression + "\n}";

I didn't put the newlines back originally so the line numbers for the evaluated expression would not change by adding the with() {}. Can you just add the suffix newline and keep the prefix newline off?
Comment 6 Joseph Pecoraro 2013-05-17 11:18:10 PDT
Created attachment 202120 [details]
[PATCH] Updated Patch
Comment 7 Joseph Pecoraro 2013-05-17 11:19:17 PDT
(In reply to comment #2)
> I think it is cleaner to have a newline before and after the expression. Especially if you add a sourceURL or debugger statement. That does mean exceptions / errors might be off by 1 in their stack trace. But we should do a better job there anyways.

Timothy Hatcher's review comment made me drop the prefix newline. New patch up.
Comment 8 WebKit Commit Bot 2013-05-17 11:48:36 PDT
Comment on attachment 202120 [details]
[PATCH] Updated Patch

Clearing flags on attachment: 202120

Committed r150280: <http://trac.webkit.org/changeset/150280>
Comment 9 WebKit Commit Bot 2013-05-17 11:48:38 PDT
All reviewed patches have been landed.  Closing bug.