<?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>11401</bug_id>
          
          <creation_ts>2006-10-24 08:29:32 -0700</creation_ts>
          <short_desc>Web Inspector doesn&apos;t understand object.method = function() {} syntax</short_desc>
          <delta_ts>2013-07-16 08:19:42 -0700</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 (Deprecated)</component>
          <version>420+</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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="Jonathan Hurshman">jhurshman</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aroben</cc>
    
    <cc>cederberg</cc>
    
    <cc>joepeck</cc>
    
    <cc>marcus</cc>
    
    <cc>mrowe</cc>
    
    <cc>rik</cc>
    
    <cc>timothy</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>50831</commentid>
    <comment_count>0</comment_count>
    <who name="Jonathan Hurshman">jhurshman</who>
    <bug_when>2006-10-24 08:29:32 -0700</bug_when>
    <thetext>Drosera&apos;s function list will list as &quot;(anonymous function)&quot; any function defined using the syntax:

SomeObject.someMethod = function(a, b) {
...
}

or

SomeObject.prototype.someMethod = function(a, b) {
...
}

This makes the function list not very useful if this particular syntax is frequently used (as it is in the projects I work on).

Please enable Drosera to determine the function name for methods defined by such syntax.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50574</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2006-10-24 14:26:42 -0700</bug_when>
    <thetext>It is obvious why this is desirable, but what is less obvious is the difficulty in providing this.  At the time the function object is created, it is anonymous.  Assigning it to a variable or to property on another object does not change this fact.  Consider the following example:
SomeObject.someMethod = function(a, b) { };
SomeOtherObject.someOtherMethod = SomeObject.someMethod;
SomeOtherObject.someOtherMethod(1, 2);

What name should Drosera give to the frame created by the function call in the third line?  Coming up with a solution to this single case appears relatively easy, but is tricky to generalise in a fashion that won&apos;t produce more confusing results in some cases.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50022</commentid>
    <comment_count>2</comment_count>
    <who name="Jonathan Hurshman">jhurshman</who>
    <bug_when>2006-10-24 19:14:53 -0700</bug_when>
    <thetext>I agree, it is tricky. For what it&apos;s worth, here&apos;s what I&apos;ve gathered from my observation of other debugging environments, based on this example:

      function SomeObject() { }     
      function SomeObject2() { }
      
      SomeObject.methodA = function() { 
        var a = &quot;A&quot;; 
      };
      
      var tempMethod = function() {
        var b = &quot;B&quot;;
      };
      
      SomeObject.prototype.methodB = tempMethod;
      SomeObject.prototype.methodC = SomeObject.methodA;
      SomeObject2.prototype.methodD = SomeObject.prototype.methodB;
      
      function test() {
        var a = new SomeObject();
        var b = new SomeObject2();
        SomeObject.methodA();
        a.methodC();
        a.methodB();
        b.methodD();
        
      }

Venkman labels functions with the name of what the function literal is originally assigned to. For this example, Venkman lists two methods labeled &quot;methodA&quot; and &quot;tempMethod&quot;, both in the function list and in the call stack.

Firebug just goes with &quot;anonymous&quot;, like Drosera currently does. I don&apos;t have a Windows machine handy to test Visual Studio&apos;s debugger.

Not knowing anything about how Drosera does its thing, I don&apos;t know how this would work, but it seems to me that the ideal solution would go beyond Venkman&apos;s. It would be great if it would show both the constructor-name-of-&apos;this&apos; and the callee name, as well as referencing the name and context of the original name.

Maybe something along the lines of:

SomeObject.methodA
SomeObject.prototype.methodC -&gt; SomeObject.methodA
SomeObject.prototype.methodB -&gt; window.tempMethod
SomeObject2.prototype.methodD -&gt; window.tempMethod

That&apos;s getting a bit verbose, but I don&apos;t think it would cause confusion.

I must say that I have done heavy-duty JavaScript/AJAX development using Venkman for several years, and I have never once been confused by their function labels. So that solution, while not ideal, appears to me to be adequate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47541</commentid>
    <comment_count>3</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2006-11-02 09:20:33 -0800</bug_when>
    <thetext>Related to bug 9596.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46836</commentid>
    <comment_count>4</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2006-11-05 21:34:13 -0800</bug_when>
    <thetext>Related to bug 11525.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73435</commentid>
    <comment_count>5</comment_count>
    <who name="Per Cederberg">cederberg</who>
    <bug_when>2008-03-11 23:46:50 -0700</bug_when>
    <thetext>I&apos;ve noted that the MochiKit JavaScript library allows assigning a &quot;NAME&quot; property to anonymous functions. I guess other libraries could have similar mechanisms (as the ordinary function &quot;name&quot; property is read-only).

Perhaps a work-around for this issue would be for Drosera to print the &quot;NAME&quot; value if &quot;name&quot; is undefined? It is pretty easy to name all functions in a namespace with this method by iterating over all properties, objects and prototypes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73690</commentid>
    <comment_count>6</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2008-03-13 23:04:57 -0700</bug_when>
    <thetext>Coming up with a good system here would make debugging the Inspector a lot easier.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80705</commentid>
    <comment_count>7</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2008-05-17 09:20:24 -0700</bug_when>
    <thetext>Still applies to the Web Inspector debugger, moving to that component.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>152049</commentid>
    <comment_count>8</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2009-10-02 22:48:57 -0700</bug_when>
    <thetext>Is this solved by the Inspector using function&apos;s &quot;displayName&quot; property like comment 5 suggests and as detailed in this April 2009 article:
http://www.alertdebugging.com/2009/04/29/building-a-better-javascript-profiler-with-webkit/

For the example in this bug report:

  SomeObj.someMethod = function(a,b) { ... };
  SomeObj.someMethod.displayName = &apos;SomeObj.someMethod&apos;;

Will properly display SomeObj.someMethod in the profiler.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>908896</commentid>
    <comment_count>9</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2013-07-16 08:19:42 -0700</bug_when>
    <thetext>We also auto detect the name now. Try the latest nightly.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>