RESOLVED DUPLICATE of bug 137306 Bug 139655
Web Inspector: functions and accessors not shown when debugger paused in constructor
https://bugs.webkit.org/show_bug.cgi?id=139655
Summary Web Inspector: functions and accessors not shown when debugger paused in cons...
Brian Burg
Reported 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();
Attachments
Better test case (628 bytes, text/html)
2014-12-15 15:12 PST, Brian Burg
no flags
Joseph Pecoraro
Comment 1 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?
Joseph Pecoraro
Comment 2 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.
Brian Burg
Comment 3 2014-12-15 15:12:47 PST
Created attachment 243313 [details] Better test case
Joseph Pecoraro
Comment 4 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 ***
Note You need to log in before you can comment on or make changes to this bug.