[webidl.js] Implement the any type

Hi guys, I found yet another possible issue with the WebIDL spec.


In the "any" conversion algorithm, it's specified that if the ECMAScript value is a Number, it should be converted using the 'double' conversion at section 4.2.14. 

  [http://dev.w3.org/2006/webapi/WebIDL/#es-any]

In this section, it's said to throw a type error if the number has the value "NaN" or is infinite.

  [http://dev.w3.org/2006/webapi/WebIDL/#es-double]


I can prove this is not what browsers do by looking at the setTimeout function, which takes 'any' arguments. 

  [http://www.w3.org/TR/2011/WD-html5-20110525/timers.html#timers]

In the 'get timeout' algorithm that converts the received value into a number, we can read the following:

  "If timeout is an Infinity value, a Not-a-Number (NaN) value, or negative, let timeout be zero."
  [http://www.w3.org/TR/2011/WD-html5-20110525/timers.html#get-the-timeout]

I tried calling setTimeout(alert, Number.NaN) and that works perfectly fine in all browsers (alert is executed straightaway), and that doesn't throw a conversion type error because of the 4.2.14 algorithm.

My belief is that the specification should have referenced the "4.2.15 unrestricted double" algorithm instead.


I sent this mail in CC to Cameron & the public-script-coord mailing list, let's see what their response will be. 		 	   		  

Received on Thursday, 10 January 2013 11:01:59 UTC