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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>11857</bug_id>
          
          <creation_ts>2011-01-25 06:30:59 +0000</creation_ts>
          <short_desc>getData() with no or too many arguments should throw</short_desc>
          <delta_ts>2011-08-04 05:17:16 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</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="Hallvord R. M. Steen">hsteen</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>cam</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>44696</commentid>
    <comment_count>0</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-01-25 06:30:59 +0000</bug_when>
    <thetext>Because that&apos;s what I see Chrome do, so that&apos;s how I spec&apos;ed it :-p

On a less flippant note, calling this method without arguments or with too many is probably a mistake that implementations should flag early.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45663</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-02-16 08:36:03 +0000</bug_when>
    <thetext>getData()?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45702</commentid>
    <comment_count>2</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-02-16 11:22:20 +0000</bug_when>
    <thetext>Heh, too deep inside what I was writing to be really clear.. This getData():
http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dom-datatransfer-getdata</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47908</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-05-03 22:09:06 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Did Not Understand Request
Change Description: no spec change
Rationale: I don&apos;t understand what it is you want me to change. There&apos;s nothing special about getData(), it&apos;s just a one-argument function, and it works the same regarding handling missing or extra arguments as all other functions, as defined by WebIDL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48089</commentid>
    <comment_count>4</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-05-05 15:07:06 +0000</bug_when>
    <thetext>OK, I don&apos;t understand (yet) how to piece together the HTML5 and WebIDL specs to get the full picture. Guess &quot;3. If S is empty, throw a TypeError.&quot; under http://dev.w3.org/2006/webapi/WebIDL/#es-operations is what I&apos;m missing.

Chrome raises a SyntaxError, not a TypeError though. Does that mean the IDL in the HTML5 spec should change

  DOMString getData(in DOMString format);

to

  DOMString getData(in DOMString format) raises SyntaxError;

?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48127</commentid>
    <comment_count>5</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-05-05 23:18:07 +0000</bug_when>
    <thetext>Please note that the plan is to make functions calls with too few or too many arguments *not* to throw (mentioned in http://lists.w3.org/Archives/Public/public-script-coord/2010OctDec/0094.html).  `aDataTransfer.getData()` would thus be equivalent to `aDataTransfer.getData(&quot;undefined&quot;)`.

raises() clauses are entirely optional -- implementations of IDL operations are allowed to throw exceptions that are not listed in a raises() clause.  Also, TypeError and SyntaxError are not concepts that exist at the IDL level.  Only exceptions explicitly defined in IDL can be listed there.  (It may make sense to change that, in the spirit of &quot;serve JS first, allow other languages second&quot;.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48165</commentid>
    <comment_count>6</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-05-06 01:35:41 +0000</bug_when>
    <thetext>Makes sense to me not to throw by default - it&apos;s not like JS is consistent anyway..

Unless WebIDL defines an extended attribute [ThrowsIfNumberOfArgumentsIsUnexpected] or something like that, individual specs should say in the prose what happens. (Then again, it would be nice to have a way to indicate this in the IDL without repeating such things in prose all over the place.. A related question - JS only - is how methods behave if they are called with an unexpected this object. There is no IDL attribute to indicate whether i.e. &quot;window.alert.call(document, &apos;Do you see this alert?&apos;)&quot; should throw? But now I&apos;m off-topic..) 

I think that means it&apos;s over to you again, Ian ;) I propose adding a sentence more or less like 

&quot;If getData() is called with less than or more than one single argument, the implementation must throw a SyntaxError exception.&quot;

(Opera&apos;s old WRONG_ARGUMENTS_ERROR would have been nice but I think we never got that into a spec? Haven&apos;t looked it up, so I may be plain wrong.. In any case better to just follow WebKit on this.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48339</commentid>
    <comment_count>7</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-05-08 23:56:40 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; A related question - JS only - is how methods behave if
&gt; they are called with an unexpected this object. There is no IDL attribute to
&gt; indicate whether i.e. &quot;window.alert.call(document, &apos;Do you see this alert?&apos;)&quot;
&gt; should throw? But now I&apos;m off-topic..

You&apos;re right, Web IDL doesn&apos;t make this throw.  I thought I had wording in there to make it throw, but I can&apos;t see any.  I think there should be a step in http://dev.w3.org/2006/webapi/WebIDL/#es-operations that checks that the this object is of the right type and throws a TypeError if it is not.  Filed bug 12635 for that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48398</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-05-10 03:33:33 +0000</bug_when>
    <thetext>What is special about getData() here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48420</commentid>
    <comment_count>9</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2011-05-10 11:53:53 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; individual
&gt; specs should say in the prose what happens.

I strongly object to this. This should all be defined in WebIDL and all specifications should use the default behaviour, unless there is strong compat risk to that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48466</commentid>
    <comment_count>10</comment_count>
    <who name="Hallvord R. M. Steen">hsteen</who>
    <bug_when>2011-05-11 05:29:15 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; What is special about getData() here?

*If* most other methods defined by the implementation do not throw when called with too many or too few arguments, doing so makes getData() special.

I don&apos;t know if that is the case. 

Having thought a bit more, I now think it would make sense to throw by default, because AFAIK WebIDL already has a way to mark methods that accept a variable number of arguments. Going forward, spec authors should be required to mark up those methods accordingly and the rest should throw.

If Cameron agrees with that we can close this bug again :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49959</commentid>
    <comment_count>11</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-06-21 05:41:32 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale: getData() is not special here</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49963</commentid>
    <comment_count>12</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-06-21 05:49:03 +0000</bug_when>
    <thetext>(In reply to comment #10)
&gt; Having thought a bit more, I now think it would make sense to throw by default,
&gt; because AFAIK WebIDL already has a way to mark methods that accept a variable
&gt; number of arguments. Going forward, spec authors should be required to mark up
&gt; those methods accordingly and the rest should throw.
&gt; 
&gt; If Cameron agrees with that we can close this bug again :-)

Sorry, I missed this comment until now.  Web IDL recently changed to throw if too few arguments are passed, but to ignore any extra arguments.  Specs shouldn&apos;t override this unless they have good reason to (e.g. web compatibility concerns).  I haven&apos;t added any syntactic facility to do this overriding in the IDL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53778</commentid>
    <comment_count>13</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:17:16 +0000</bug_when>
    <thetext>mass-move component to LC1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>