<?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>114457</bug_id>
          
          <creation_ts>2013-04-11 12:29:14 -0700</creation_ts>
          <short_desc>typeof non-callback interfaces without [NoInterfaceObject] should be &quot;function&quot;</short_desc>
          <delta_ts>2022-09-04 13:11:26 -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>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>EasyFix, WebExposed</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Erik Arvidsson">arv</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>aroben</cc>
    
    <cc>bfulgham</cc>
    
    <cc>cdumez</cc>
    
    <cc>ggaren</cc>
    
    <cc>glenn</cc>
    
    <cc>heycam</cc>
    
    <cc>oliver</cc>
    
    <cc>rniwa</cc>
    
    <cc>sam</cc>
    
    <cc>syoichi</cc>
    
    <cc>zan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>874031</commentid>
    <comment_count>0</comment_count>
    <who name="Erik Arvidsson">arv</who>
    <bug_when>2013-04-11 12:29:14 -0700</bug_when>
    <thetext>typeof HTMLElement is &quot;function&quot; in IE, Firefox and Chrome. Safari (WebKit+JSC) is the only one that returns &quot;object&quot; here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874053</commentid>
    <comment_count>1</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2013-04-11 12:43:31 -0700</bug_when>
    <thetext>is HTMLElement a constructor now?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874060</commentid>
    <comment_count>2</comment_count>
    <who name="Erik Arvidsson">arv</who>
    <bug_when>2013-04-11 12:49:04 -0700</bug_when>
    <thetext>It is not constructable but it has a prototype.

This is speced in WebIDL:

http://dev.w3.org/2006/webapi/WebIDL/#interface-object

&gt; The interface object for a given non-callback interface is a function object.

-------------------

WebKit also returns `&quot;object&quot;` for `typeof XMLHttpRequest` which is clearly constructable. ;-)

----------------------

The DOM interface objects are like:

class HTMLElement extends Element {
  constructor() {
    throw new TypeError(&apos;Illegal constructor&apos;);
  }
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874065</commentid>
    <comment_count>3</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2013-04-11 12:54:51 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; It is not constructable but it has a prototype.
&gt; 
&gt; This is speced in WebIDL:
&gt; 
&gt; http://dev.w3.org/2006/webapi/WebIDL/#interface-object
&gt; 
&gt; &gt; The interface object for a given non-callback interface is a function object.
&gt; 
&gt; -------------------
&gt; 
&gt; WebKit also returns `&quot;object&quot;` for `typeof XMLHttpRequest` which is clearly constructable. ;-)
&gt; 
&gt; ----------------------
&gt; 
&gt; The DOM interface objects are like:
&gt; 
&gt; class HTMLElement extends Element {
&gt;   constructor() {
&gt;     throw new TypeError(&apos;Illegal constructor&apos;);
&gt;   }
&gt; }

It&apos;s really defined as being a constructor, but throws anyway? why?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874070</commentid>
    <comment_count>4</comment_count>
    <who name="Erik Arvidsson">arv</who>
    <bug_when>2013-04-11 12:59:31 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; It&apos;s really defined as being a constructor, but throws anyway? why?

Consistency.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874085</commentid>
    <comment_count>5</comment_count>
    <who name="Glenn Adams">glenn</who>
    <bug_when>2013-04-11 13:13:08 -0700</bug_when>
    <thetext>My reading of WebIDL 4.4 [1] is that there is a more general requirement for non-callback interfaces that are not declared with [NoInterfaceObject], namely that:

(1) a corresponding property must exist on the ECMAScript global object;
(2) the name of the property is the identifier of the interface;
(3) its value is an object called the interface object; and
(4) the interface object for a given non-callback interface is a function object.

In some W3C CSSOM incoming tests [2], one can see how CSSStyleDeclaration is not instanceof Function on Safari, but works on FF and Opera.

So it isn&apos;t just HTMLElement.

[1] http://www.w3.org/TR/WebIDL/#es-interfaces
[2] http://hg.csswg.org/test/raw-file/default/contributors/gadams/incoming/cssom/cssstyledeclaration-interface.xht</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874097</commentid>
    <comment_count>6</comment_count>
    <who name="Erik Arvidsson">arv</who>
    <bug_when>2013-04-11 13:20:04 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; In some W3C CSSOM incoming tests [2], one can see how CSSStyleDeclaration is not instanceof Function on Safari, but works on FF and Opera.
&gt; 
&gt; So it isn&apos;t just HTMLElement.

Yeah, this all interface objects in WebKit. Even clearly constructable ones (like XMLHttpRequest and Image).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874145</commentid>
    <comment_count>7</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2013-04-11 13:58:43 -0700</bug_when>
    <thetext>Our behavior is correct here - HTMLElement is not callable, and therefore ECMAScript requires us to report it as type &quot;object&quot;.

The bug (if you will) is that HTMLElement, etc aren&apos;t callable, and that instead they should be functions that are useless</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874151</commentid>
    <comment_count>8</comment_count>
    <who name="Glenn Adams">glenn</who>
    <bug_when>2013-04-11 14:08:06 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; Our behavior is correct here - HTMLElement is not callable, and therefore ECMAScript requires us to report it as type &quot;object&quot;.
&gt; 
&gt; The bug (if you will) is that HTMLElement, etc aren&apos;t callable, and that instead they should be functions that are useless

I concur that typeof(HTMLElement), typeof(CSSStyleDeclaration), etc., should be object, but that the type of the object should be a Function object, i.e., that HTMLElement instanceof Function be true. Are we agreeing?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874155</commentid>
    <comment_count>9</comment_count>
    <who name="Glenn Adams">glenn</who>
    <bug_when>2013-04-11 14:10:17 -0700</bug_when>
    <thetext>In which case this bug should be closed as INVALID and a new bug opened on instanceof HTMLElement et al, yes?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874156</commentid>
    <comment_count>10</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2013-04-11 14:11:32 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; In which case this bug should be closed as INVALID and a new bug opened on instanceof HTMLElement et al, yes?

I think that&apos;s possibly best (new bug will avoid confusion caused by initial description)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874169</commentid>
    <comment_count>11</comment_count>
    <who name="Erik Arvidsson">arv</who>
    <bug_when>2013-04-11 14:37:49 -0700</bug_when>
    <thetext>http://dev.w3.org/2006/webapi/WebIDL/#es-interface-call

&quot;The internal [[Call]] method of the interface object behaves as follows, assuming arg0..n−1 is the list of argument values passed to the constructor, and I is the interface:

1. If I was not declared with a [Constructor] extended attribute, then throw a TypeError.&quot;

Do we want to change the spec (which is correctly implemented today in 3 out 4 browsers)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>874227</commentid>
    <comment_count>12</comment_count>
    <who name="Cameron McCormack (:heycam)">heycam</who>
    <bug_when>2013-04-11 15:31:09 -0700</bug_when>
    <thetext>My intention in the spec was to move towards typeof HTMLElement being &quot;function&quot;, and HTMLElement being a regular function object.  Having HTMLElement be callable but its [[Call]] throwing an exception was the way to do that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1078555</commentid>
    <comment_count>13</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2015-03-19 10:37:50 -0700</bug_when>
    <thetext>This causes the CustomEvent polyfill to be used in Safari even though CustomEvent is supported natively. See https://github.com/krambuhl/custom-event-polyfill/blob/eeb828bf89631ae4dc91efc1e8f508910ab41961/custom-event-polyfill.js#L7 which checks window.CustomEvent !== &quot;function&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1896017</commentid>
    <comment_count>14</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-09-03 04:46:25 -0700</bug_when>
    <thetext>rniwa@webkit.org - Is this still an issue or needed? Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1896202</commentid>
    <comment_count>15</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2022-09-04 13:11:26 -0700</bug_when>
    <thetext>I believe we did work through all these issues. The simple &quot;typeof HTMLElement&quot; does say &quot;function&quot;, although it wasn&apos;t quite straightforward to get there.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>