Open Honry opened 6 years ago
This is a similar problem as with pointer device input, which in https://w3c.github.io/webdriver/#actions is solved by having a notion of ticks and pausing to send a whole series of updates in one command.
Something similar might work for sensor readings, given how similar the data flow is.
A potential problem with having JS generate sensor readings is where that script will execute. To not make assumptions about where the sensor readings are being inserted, it may be necessary to isolate that script similar to how worklets are defined: https://drafts.css-houdini.org/worklets/#worklet
https://webaudio.github.io/web-audio-api/#audioworklet is a bit similar to what might be needed, although that's a web-exposed API.
@foolip could you comment on the need to address this in WebDriver? I'm starting to think that the "browser implementer" use case is addressed by @Honry's patch and that the "web app developer" use case is addressed by pure JavaScript mocks. Are there any situations where one of those two approaches will be insufficient?
Since Sensor
doesn't have a constructor it won't be possible to perfectly mock the API for a web developer, but I believe it will be possible to mock out sensors well enough to run any tests that are verifying the behavior of a web app as opposed to the browser itself.
Whenever possible I think it'd be good to serve the testing needs of web developers with WebDriver as well, but this is a case where doing so would add significant complexity. So, my inclination would be to not tackle that unless requests from real web developers attempting to use the existing proposed API come in.
This thread is separated from https://github.com/w3c/sensors/pull/369 (Introduce WebDriver Extension API) to discuss about supporting multiple HTTP requests for the use case of simulating a series of updating mock sensor readings. Thanks @jugglinmike for proposing a great idea!
Posted @jugglinmike's comments: (https://github.com/w3c/sensors/pull/369#pullrequestreview-147716129)
(https://github.com/w3c/sensors/pull/369#issuecomment-414760073)
(https://github.com/w3c/sensors/pull/369#issuecomment-415147560)