Bug 139655 - Web Inspector: functions and accessors not shown when debugger paused in constructor
Summary: Web Inspector: functions and accessors not shown when debugger paused in cons...
Status: RESOLVED DUPLICATE of bug 137306
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:
Depends on:
Blocks:
 
Reported: 2014-12-15 14:56 PST by Brian Burg
Modified: 2014-12-16 11:16 PST (History)
4 users (show)

See Also:


Attachments
Better test case (628 bytes, text/html)
2014-12-15 15:12 PST, Brian Burg
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Burg 2014-12-15 14:56:27 PST
As I understand it, the new operator creates an empty object, sets the prototype field, then calls the constructor. However, functions from the prototype do not show up in autocomplete or the details sidebar when the debugger pauses within a constructor.

Test case:

Foo = new function() {
    this._luckyNumber = 3;
    debugger;
}

Foo.prototype = {
    get luck() { return this._luckyNumber; },
    set luck(v) { this._luckyNumber = v; },
    toString: function() { return "" + this._luckyNumber; }
}
    
var f = new Foo();
f.luck = 4;
f.luck;
f.toString();
Comment 1 Joseph Pecoraro 2014-12-15 15:04:23 PST
> Foo = new function() {
>     this._luckyNumber = 3;
>     debugger;
> }
>
> [snip]
> 
> var f = new Foo();

As written, this causes an exception. Since you are doing "Foo = new function" up above and then "new Foo".

    [Error] TypeError: Object is not a constructor (evaluating 'new Foo()')

Things behave as expected when you create the constructor:

    function Foo() {
        this._luckyNumber = 3;
        debugger;
    }

Is there still an issue here?
Comment 2 Joseph Pecoraro 2014-12-15 15:05:50 PST
(In reply to comment #0)
> As I understand it, the new operator creates an empty object, sets the
> prototype field, then calls the constructor. However, functions from the
> prototype do not show up in autocomplete or the details sidebar when the
> debugger pauses within a constructor.
> 
> Test case:
> 
> Foo = new function() {
>     this._luckyNumber = 3;
>     debugger;
> }
> 
> Foo.prototype = {
>     get luck() { return this._luckyNumber; },
>     set luck(v) { this._luckyNumber = v; },
>     toString: function() { return "" + this._luckyNumber; }
> }

Also, as written the debugger pauses inside the "new function" without having assigned the prototype yet. So the debugger was behaving correctly then.
Comment 3 Brian Burg 2014-12-15 15:12:47 PST
Created attachment 243313 [details]
Better test case
Comment 4 Joseph Pecoraro 2014-12-16 11:16:20 PST
The test case behaves as expected right now, but can be improved. The console autocompletes prototype properties, and expanding this -> proto -> you see luck getter / setters.

We are looking to improve the object display (Object Properties tree) in:
<https://webkit.org/b/137306> Web Inspector: Expanding event objects in console shows undefined for most values, it should have real values

Specifically:
https://bugs.webkit.org/show_bug.cgi?id=137306#c3

Lets dup?

*** This bug has been marked as a duplicate of bug 137306 ***