Bug 116292 - Web Inspector: SyntaxError evaluating "1+1; //@ sourceURL=test" in console
Summary: Web Inspector: SyntaxError evaluating "1+1; //@ sourceURL=test" in console
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-05-16 23:02 PDT by Joseph Pecoraro
Modified: 2013-05-17 11:48 PDT (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (4.22 KB, patch)
2013-05-16 23:26 PDT, Joseph Pecoraro
timothy: review+
Details | Formatted Diff | Diff
[PATCH] Updated Patch (3.47 KB, patch)
2013-05-17 11:18 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-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.