Bug 83267

Summary: Web Inspector: [JSC] "SyntaxError: 'with' statements are not valid in strict mode" when debugging strict mode script
Product: WebKit Reporter: Matthew Caruana Galizia <matt.cg>
Component: Web Inspector (Deprecated)Assignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: apavlov, bweinstein, gavin, joepeck, keishi, loislo, mark.lam, oliver, o.smestad, pfeldman, pmuellr, pom, rik, spam, timothy, yeecheng.chin+webkit, yurys
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.6   

Matthew Caruana Galizia
Reported 2012-04-05 04:48:02 PDT
Steps to reproduce: 1) Write a script with the "strict mode" flag at the top 2) Insert a breakpoint in your script and run something that will trigger a pause on that breakpoint 3) Open the console and attempt to evaluate something while execution is paused e.g. type 'this' and hit enter What should happen: The entered script should be evaluated. What happens instead: A SyntaxError with the message "'with' statements are not valid in strict mode" is thrown.
Attachments
Timothy Hatcher
Comment 1 2012-04-18 12:55:07 PDT
Gavin Kistner
Comment 2 2012-07-25 09:48:11 PDT
If there is a Radar bug for this, is it safe to say that the status is confirmed? This is a really bad problem, especially when attempting to debug new problems introduced specifically by Safari 6.0: http://meta.stackoverflow.com/questions/134611/safari-is-asking-if-i-want-to-leave-the-page-when-saving-my-edits
Timothy Hatcher
Comment 3 2012-10-15 11:43:23 PDT
*** Bug 99305 has been marked as a duplicate of this bug. ***
Yury Semikhatsky
Comment 4 2012-10-16 01:18:55 PDT
Works fine in tip of tree Chromium and 23.0.1271.26 (Official Build 160934) beta.
yeecheng.chin+webkit
Comment 5 2012-10-18 03:18:13 PDT
Hi, is there a reason this bug is still unconfirmed, let alone fixed? It's a pretty simple, very easy to reproduce bug, and significantly discourages developers from developing strict mode code on Safari. Basically in the inspector console, there's a hidden object "window.console._commandLineAPI" that provides some console functionality like "$", "clear" etc. There's a function called evaluateOnCallFrame (defined in InjectedScriptSource.js) that the console tries to call to wrap whatever code it's calling in a with statement to wrap around the command line api object so those functions appear on the global scope. The with statement is obviously not legal in strict mode hence the exception. I took at look at Chrome and couldn't figure out what they are doing differently but running code in console under strict mode does work, unlike Safari. My suggestion is either: 1) Don't execute code under strict mode when in the inspector console. This is a one line fix in DebuggerCallFrame::evaluate. Basically instead of passing along the intended strict mode setting, just pass false to EvalExecutable::create. This is kind of a hack as the console won't be giving you the correct results (e.g. error when you try to call arguments.callee), but at least the console will work! 2) Find some better ways to wrap the command line API. I'm not sure what Chrome does, but maybe we do can something like the following instead of using a with statement to wrap? (function() { var $ = window.console._commandLineAPI.$; var $$ = window.console._commandLineAPI.$$; var clear = window.console._commandLineAPI.clear; ... // The actual code the console is trying to run // This has an issue of masking out the global variables and other stack variables but there are ways to get around that )(); Either way I think it's better to get something working than the console being plain broken under strict mode!
Øyvind Smestad
Comment 6 2012-12-10 04:24:51 PST
This seems to be a duplicate of: https://bugs.webkit.org/show_bug.cgi?id=65829
JP Grace
Comment 7 2012-12-18 13:16:19 PST
How is this still not fixed? It appears to be a duplicate of: https://bugs.webkit.org/show_bug.cgi?id=65829 that dates back to over a year ago. I cannot debug anything in Safari as a result of this bug. It's embarrassing. Can we please prioritize this?
Timothy Hatcher
Comment 8 2013-03-21 15:03:53 PDT
*** This bug has been marked as a duplicate of bug 65829 ***
Note You need to log in before you can comment on or make changes to this bug.