[Webkit-unassigned] [Bug 83267] Web Inspector: "SyntaxError: 'with' statements are not valid in strict mode" when debugging strict mode script

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Oct 18 03:17:20 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=83267


yeecheng.chin+webkit at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yeecheng.chin+webkit at gmail.
                   |                            |com




--- Comment #5 from yeecheng.chin+webkit at gmail.com  2012-10-18 03:18:13 PST ---
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!

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list