Bug 115242

Summary: Web Inspector: expose the JS parser to the protocol
Product: WebKit Reporter: Timothy Hatcher <timothy>
Component: Web Inspector (Deprecated)Assignee: Timothy Hatcher <timothy>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, eflews.bot, graouts, gyuyoung.kim, joepeck, oliver, rego+ews, timothy, webkit-ews, xan.lopez
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Timothy Hatcher 2013-04-26 04:20:22 PDT
We should add RuntimeAgent.parse to get access to parse errors for use in the console prompt.
Comment 1 Timothy Hatcher 2013-04-26 04:23:34 PDT
Created attachment 199811 [details]
Patch
Comment 2 Early Warning System Bot 2013-04-26 04:28:14 PDT
Comment on attachment 199811 [details]
Patch

Attachment 199811 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/43804
Comment 3 EFL EWS Bot 2013-04-26 04:28:37 PDT
Comment on attachment 199811 [details]
Patch

Attachment 199811 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/236076
Comment 4 EFL EWS Bot 2013-04-26 04:28:54 PDT
Comment on attachment 199811 [details]
Patch

Attachment 199811 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/26979
Comment 5 Early Warning System Bot 2013-04-26 04:29:43 PDT
Comment on attachment 199811 [details]
Patch

Attachment 199811 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/226170
Comment 6 Build Bot 2013-04-26 04:57:45 PDT
Comment on attachment 199811 [details]
Patch

Attachment 199811 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/126369
Comment 7 Timothy Hatcher 2013-04-26 05:46:33 PDT
Created attachment 199818 [details]
Patch
Comment 8 Build Bot 2013-04-26 06:11:32 PDT
Comment on attachment 199818 [details]
Patch

Attachment 199818 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/126394
Comment 9 Timothy Hatcher 2013-04-26 09:05:07 PDT
Created attachment 199838 [details]
Patch
Comment 10 Build Bot 2013-04-26 10:32:00 PDT
Comment on attachment 199838 [details]
Patch

Attachment 199838 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/65425
Comment 11 Timothy Hatcher 2013-04-26 10:34:08 PDT
Created attachment 199841 [details]
Patch
Comment 12 Timothy Hatcher 2013-04-26 10:51:59 PDT
Comment on attachment 199841 [details]
Patch

Need to fix Windows build before landing.
Comment 13 Timothy Hatcher 2013-04-26 10:55:57 PDT
Created attachment 199844 [details]
Patch
Comment 14 WebKit Commit Bot 2013-04-26 12:07:30 PDT
Comment on attachment 199844 [details]
Patch

Clearing flags on attachment: 199844

Committed r149202: <http://trac.webkit.org/changeset/149202>
Comment 15 WebKit Commit Bot 2013-04-26 12:07:34 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Joseph Pecoraro 2013-04-26 12:51:39 PDT
Comment on attachment 199844 [details]
Patch

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

Nice!

> Source/WebCore/inspector/Inspector.json:671
> +                "description": "Syntax error type: \"none\" for no error, \"irrecoverable\" for unrecoverable errors, \"unterminated-literal\" for when there is an unterminated literal, \"recoverable\" for when the expression is unfinished but valid so far."

Some of the descriptions have <code>foo</code> instead of \"foo\". I think its easier to read the <code> versions. Maybe one day we can format this file as documentation nicely, like: <https://developers.google.com/chrome-developer-tools/docs/protocol/tot/console>

> Source/WebCore/inspector/InspectorRuntimeAgent.cpp:99
> +    checkSyntax(*vm, JSC::makeSource(expression), error);

When on a breakpoint, we may want to inherit the Strict versus Non-Strict mode scope we are in and pass that into checkSyntax, which currently hardcodes JSParseNormal. There are syntax errors that can happen in strict mode that can't in normal mode, e.g. duplicate object literal keys:

    js> var o = { x:1, x:2 }; o.x
    2

    js> "use strict"; var o = { x:1, x:2 }; o.x
    Exception: SyntaxError: Unexpected token '}'

I can file a follow-up bug on this edge case.

> Source/WebCore/inspector/InspectorRuntimeAgent.h:64
> +    virtual void parse(ErrorString*, const String& expression, TypeBuilder::Runtime::SyntaxErrorType::Enum* result, TypeBuilder::OptOutput<String>* message, RefPtr<TypeBuilder::Runtime::ErrorRange>&);

We should consider starting to add OVERRIDE to these, to help catch dead code if a protocol method is removed (rare or accidental), the compiler can tell us.