Interaction of dictionaries and platform objects is a bit weird

Consider the following IDL:

   dictionary Dict {
     long a;
   };
   [Constructor()]
   interface Iface {
     void foo(long x, optional Dict y);
     void bar(optional Dict z);
     void bar(Element w);
   };

and this script, running in a web page:

   var x = new Iface();
   x.foo(5, document);
   x.bar(document);

What happens?

As far as I can tell, the foo() call succeeds.  The "a" property of the 
document, if any, is placed in the dictionary, and then the number 5 and 
the dictionary are passed to the WebIDL method implementation.

Also as far as I can tell the call bar() call throws.  This is because 
we enter the overload resolution algorithm, set argcount to 1, throw our 
the 0-argument overload, set d to 0, examine arg 0, determine that it 
does not satisfy either overload (because document does not implement 
Element and because document is a platform object, so never enters step 
13.6 of the overload resolution algorithm), and a TypeError is thrown.

This seems a bit odd.  I think we should either always throw a TypeError 
when converting platform objects to dictionaries or allow any object to 
enter step 13.6 of overload resolution... at least for dictionaries; not 
sure about callbacks.  Maybe dictionaries need to be split out into a 
separate step here?

-Boris

Received on Thursday, 18 October 2012 02:09:08 UTC