04:04
<kaiido>

Hello,
I was wondering if there is a WebIDL tool available where we could throw some inputs against a particular definition and check how the passed arguments would be converted to WebIDL values.

I saw WebIDL2.js, but as far as I can tell it only helps validate a definition, but it doesn't have a feature allowing to pass actual JS arguments to it and see which value they'd get converted to.

I would like such a tool because I am considering writing tests against a quite complex WebIDL which can accept an optional Union of unrestricted double, dictionary or a sequence of either or both. For reference this is the definition in question, particularly the radii argument.
Only by reading the WebIDL specs I am not able to do this parsing by head, because I'm not good at WebIDL and because as far as I understand, both unrestricted double and dictionary are quite open in what they do accept.

For instance I'm not sure how a radii like [], [NaN], or [undefined] should be treated (« NaN » or default dict?) or [[10]] (« 10 », or « default dict », or default dict, or « NaN »?). And what about something like arr = [10]; arr.x = 22; op(arr)? (x is a member of the expected dictionary).

So yeah, if there is a tool somewhere I could use to check all these that would be great, and if there isn't and it may be a good idea to request it somewhere I'd be glad to know where would be the best place: WebIDL repo, or maybe directly WebIDL2.js's one?
And if one of you could confirm how these particular inputs should be converted, that'd be awesome too :-D

19:55
<Domenic>
Kaiido: We have a reasonably-complete implementation of this for jsdom, which you could probably make work. It is not optimized for this purpose, e.g. it takes as input files. But I think you could do it. https://www.npmjs.com/package/webidl2js
19:56
<Domenic>
The relevant part of the Web IDL spec is the mega-algorithm https://webidl.spec.whatwg.org/#es-overloads
20:01
<Domenic>
Despite the name, it also works in the non-overload case, and takes care of all the JS -> Web IDL/infra type conversions.
20:01
<Domenic>
Learning how to walk yourself through it might pay off, although I can certainly understand the desire to have a machine-generated walkthrough instead.