Bug 141475 - Web Inspector: silent failure if introducing local variable in console when debugger paused
Summary: Web Inspector: silent failure if introducing local variable in console when d...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-02-11 08:21 PST by Brian Burg
Modified: 2016-12-13 15:33 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Burg 2015-02-11 08:21:34 PST
When the debugger is paused, running

> var x = 42;

in the console will not actually assign x to a local variable. This is fine, except that the command silently fails. If you later type

> x

while still paused, a TypeError will be thrown. This is confusing if you don't know how the console/debugger is implemented.

So, should an error be thrown when a variable is introduced when debugger is paused, or should this work somehow?
Comment 1 Radar WebKit Bug Importer 2015-02-11 08:21:54 PST
<rdar://problem/19796707>
Comment 2 Saam Barati 2015-02-11 10:47:50 PST
I would expect this to just work while debugging.
Comment 3 Timothy Hatcher 2015-02-12 09:24:54 PST
To work with strict mode we have to make a closure and call eval() inside it while paused in the debugger.

http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js#L409

The closure captures the var and it is thrown away each time. We could potentially reuse it while paused. But we really just need JSC support to avoid this hack.

It we could use with() while in strict mode, then we wouldn't need the closure.
Comment 4 Joseph Pecoraro 2016-05-20 11:42:28 PDT
So this code has changed a bunch.

I believe doing `var x` will work outside of strict mode code.

Using `let x` probably won't work in strict or non-strict. And `var` probably won't work in strict mode.

If we wanted this to work, we'd probably have to do some really tricky stuff. How do debuggers like lldb make this work? They store the result in a temporary variable, or you can create custom variables. Maybe we could approach this problem from that angle.