<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>139655</bug_id>
          
          <creation_ts>2014-12-15 14:56:27 -0800</creation_ts>
          <short_desc>Web Inspector: functions and accessors not shown when debugger paused in constructor</short_desc>
          <delta_ts>2014-12-16 11:16:20 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>137306</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Brian Burg">burg</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>graouts</cc>
    
    <cc>joepeck</cc>
    
    <cc>timothy</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1055746</commentid>
    <comment_count>0</comment_count>
    <who name="Brian Burg">burg</who>
    <bug_when>2014-12-15 14:56:27 -0800</bug_when>
    <thetext>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 &quot;&quot; + this._luckyNumber; }
}
    
var f = new Foo();
f.luck = 4;
f.luck;
f.toString();</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1055751</commentid>
    <comment_count>1</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2014-12-15 15:04:23 -0800</bug_when>
    <thetext>&gt; Foo = new function() {
&gt;     this._luckyNumber = 3;
&gt;     debugger;
&gt; }
&gt;
&gt; [snip]
&gt; 
&gt; var f = new Foo();

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

    [Error] TypeError: Object is not a constructor (evaluating &apos;new Foo()&apos;)

Things behave as expected when you create the constructor:

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

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

Also, as written the debugger pauses inside the &quot;new function&quot; without having assigned the prototype yet. So the debugger was behaving correctly then.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1055753</commentid>
    <comment_count>3</comment_count>
      <attachid>243313</attachid>
    <who name="Brian Burg">burg</who>
    <bug_when>2014-12-15 15:12:47 -0800</bug_when>
    <thetext>Created attachment 243313
Better test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1056014</commentid>
    <comment_count>4</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2014-12-16 11:16:20 -0800</bug_when>
    <thetext>The test case behaves as expected right now, but can be improved. The console autocompletes prototype properties, and expanding this -&gt; proto -&gt; you see luck getter / setters.

We are looking to improve the object display (Object Properties tree) in:
&lt;https://webkit.org/b/137306&gt; 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 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>243313</attachid>
            <date>2014-12-15 15:12:47 -0800</date>
            <delta_ts>2014-12-15 15:12:47 -0800</delta_ts>
            <desc>Better test case</desc>
            <filename>test.html</filename>
            <type>text/html</type>
            <size>628</size>
            <attacher name="Brian Burg">burg</attacher>
            
              <data encoding="base64">PCFkb2N0eXBlIGh0bWw+CjxodG1sPgo8aGVhZD4KPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3Jp
cHQiPgpGb28gPSBmdW5jdGlvbigpIHsKICAgIHRoaXMuX2x1Y2t5TnVtYmVyID0gMzsKICAgIGRl
YnVnZ2VyOwogICAgLy8gQXQgdGhpcyBwb2ludCwgbmVpdGhlciBzZXQgbHVjaygpLCBnZXQgbHVj
aygpLCBvciB0b1N0cmluZyBhcmUgaW4gdGhlIHNpZGViYXIuCiAgICAvLyBgdGhpcy5sdWNrYCB3
aWxsIGF1dG9jb21wbGV0ZSBpbiB0aGUgY29uc29sZSwgYnV0IG5vdCB0aGUgb3RoZXJzLgogICAg
Ly8gSG93ZXZlciwgYWxsIHByb3RvdHlwZSBwcm9wZXJ0aWVzIHN1Y2Nlc3NmdWxseSBldmFsdWF0
ZSBpbiBjb25zb2xlLgp9CgpGb28ucHJvdG90eXBlID0gewogICAgZ2V0IGx1Y2soKSB7IHJldHVy
biB0aGlzLl9sdWNreU51bWJlcjsgfSwKICAgIHNldCBsdWNrKHYpIHsgdGhpcy5fbHVja3lOdW1i
ZXIgPSB2OyB9LAogICAgdG9TdHJpbmc6IGZ1bmN0aW9uKCkgeyByZXR1cm4gIiIgKyB0aGlzLl9s
dWNreU51bWJlcjsgfQp9Cgp2YXIgZiA9IG5ldyBGb28oKTsKZi5sdWNrID0gNDsKZi5sdWNrOwpm
LnRvU3RyaW5nKCk7Cjwvc2NyaXB0Pgo8L2hlYWQ+Cjxib2R5PgpUZXN0CjwvYm9keT4KPGh0bWw+
Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>