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 |
Description
Matthew Caruana Galizia
2012-04-05 04:48:02 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 *** Bug 99305 has been marked as a duplicate of this bug. *** Works fine in tip of tree Chromium and 23.0.1271.26 (Official Build 160934) beta. 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! This seems to be a duplicate of: https://bugs.webkit.org/show_bug.cgi?id=65829 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? |