w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
678 stars 193 forks source link

Define WebIDL Global to host WebDriver targeted APIs #1534

Closed dontcallmedom closed 4 years ago

dontcallmedom commented 4 years ago

A number of specs have emerged to expose e.g. fake hardware as IDL interfaces to help with testing, e.g.:

Right now, these specs define their interfaces using WebIDL, but without qualifying the interfaces on the global on which they're exposed.

Since these interfaces are typically not exposed in a regular browsing context, I wonder if WebDriver should define a dedicated global on which these interfaces could be exposed (e.g. with [Exposed=WebDriverGlobal] or [Exposed=TestGlobal].)

foolip commented 4 years ago

I think that Web IDL is not an ideal fit for this, but that we're lacking a good spec formalism that could be used instead. Shameless plug for https://github.com/w3c/webdriver/issues/1510 and https://github.com/w3c/webdriver-bidi/issues/21.

Web IDL converts between ECMAScript values and "IDL values", which are the implementation-internal types. For WebDriver, the conversion is rather between a JSON serialization and some internal types.

The difference sounds trivial/pedantic, but when there isn't actually a JS engine involved at all, none of the bindings-generating code that implementations have for Web IDL would be involved. And while one can squint and make it work for simple dictionaries of strings and numbers, I think it'll stop working when we sort out https://github.com/w3c/webdriver-bidi/issues/16, and have a way to serialize values other than the subset of JS that can be represented as JSON.

Note that https://webbluetoothcg.github.io/web-bluetooth/tests.html is different, that's not defining a WebDriver API, but rather a test-only API which would be exposed in JavaScript like regular web APIs, just only in testing setups. There I think something like [TestOnly, Exposed=Window] could make sense.

foolip commented 4 years ago

Frequent Web IDL contributors @Ms2ger @domenic @TimothyGu @annevk @yasskin may have opinions about this.

domenic commented 4 years ago

WebUSB seems similar to WebBluetooth, in that https://wicg.github.io/webusb/test/#idl-index exposes a test attribute on the USB interface (which should presumably be [TestOnly]), which allows you to get access to a bunch of other interfaces that should probably be [TestOnly, Exposed=Window].

Actually, the same for WebXR.

I think none of the specs listed in the OP have much to do with WebDriver.

dontcallmedom commented 4 years ago

huh, sorry, I guess I was confused :)

So should I bring this over to the WebIDL repo then?

domenic commented 4 years ago

Yeah, that's probably the right place for it, although we'll want a combination of Web IDL domain experts and test-only API domain experts.

dontcallmedom commented 4 years ago

Raised https://github.com/heycam/webidl/issues/896 so closing this here