Bug 17593 - Figure out if something needs to be said about [[Construct]]
Figure out if something needs to be said about [[Construct]]
Status: RESOLVED INVALID
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL
unspecified
All All
: P2 normal
: ---
Assigned To: Cameron McCormack
public-webapps-bugzilla
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-25 18:31 UTC by Ms2ger
Modified: 2012-06-26 09:07 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ms2ger 2012-06-25 18:31:42 UTC
* Ms2ger tries to figure out what kind of error new window.ImageData(1,1) should throw
<bz> ms2ger: doesn't the spec say?
<Ms2ger> I'm not sure
<bz> ah
<bz> one sec
<Ms2ger> [[Construct]] doesn't appear in normative prose in WebIDL
<bz> " Interfaces that do not have a constructor will throw an exception when called as a function. "
<bz> mmmm
<Ms2ger> Only, I'm not sure if it needs to
<bz> oh, hmm
<bz> it defines a [[Call]]
<Ms2ger> Yeah
<bz> that might be a spec bug
<Ms2ger> Looking at http://ecma-international.org/ecma-262/5.1/#sec-11.2.2
<bz> and even the [[Call]] doesn't say what exception is thrown
<bz> just "an exception"
<Ms2ger> "If constructor does not implement the [[Construct]] internal method, throw a TypeError exception."
<bz> mmm
<bz> yeah
<bz> please file bugs on webidl

Cameron, please figure it out :)
Comment 1 Ms2ger 2012-06-25 18:32:41 UTC
Note to self: fix 2d.imageData.object.ctor.html when this bug is fixed.
Comment 2 Cameron McCormack 2012-06-25 23:59:28 UTC
Interface objects are function objects:

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

All function objects have the the default [[Construct]] behaviour that the ES spec defines:

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

This is regardless of whether there was a [Constructor] on the interface.

The default [[Construct]] behaviour is to create a new object and invoke [[Call]]:

  http://es5.github.com/#x13.2.2

[[Call]] will throw a TypeError if the interface was not defined with a [Constructor]:

  http://dev.w3.org/2006/webapi/WebIDL/#es-interface-call
  (scroll down to "The internal [[Call]] method ...")
Comment 3 Ms2ger 2012-06-26 09:07:16 UTC
Excellent, thanks.