w3c / compute-pressure

A web API proposal that provides information about available compute capacity
https://www.w3.org/TR/compute-pressure/
Other
69 stars 10 forks source link

Add an Automation section with WebDriver support to the spec #284

Closed rakuco closed 3 months ago

rakuco commented 3 months ago

Add WebDriver endpoints which allow manipulating virtual pressure sources, which are pressure sources whose behavior and samples are entirelly user-controlled. Also contrary to regular pressure sources, the provided samples (or, in spec parlance, a virtual pressure source's latest sample's data) are already PressureState instances rather than raw telemetry data that will be transformed into an adjusted pressure state.

Caveats:

In terms of changes to the existing algorithms and concepts:

Co-authored with @kenchris in #265. It was split off as a separate pull request to make it easier to review and understand.

Fixes #282.


Preview | Diff

rakuco commented 3 months ago

As with #283, this is part of #265 but sent separately to make it easier to review.

OrKoN commented 3 months ago

@rakuco would you be interested in defining the API as a WebDriver BiDi module as well? testdriver.js actions can also be defined in terms of WebDriver BiDi commands (https://github.com/web-platform-tests/rfcs/pull/185).

rakuco commented 3 months ago

@rakuco would you be interested in defining the API as a WebDriver BiDi module as well? testdriver.js actions can also be defined in terms of WebDriver BiDi commands (web-platform-tests/rfcs#185).

@OrKoN would there be any advantage to it? So far I've been under the impression that if an endpoint/action doesn't need WebDriver BiDi's bidirectional and event monitoring capabilities, defining a classic endpoint would be fine and achieve the same results.

OrKoN commented 3 months ago

@rakuco defining it as a WebDriver BiDi module would allow adding events later (if needed) and it would allow WebDriver BiDi-only clients such as Puppeteer to expose the functionality for developers to write tests for their apps. Although, if you only target WPT and do not need events right now, there are probably no advantages.

rakuco commented 3 months ago

Hmm, I thought Puppeteer and others like Playwright ended up using CDP directly, but it's been quite a while since I last checked. Thanks for the clarification about this.

One of the first priorities is WPT at the moment, but I've filed #288 to keep track of this as a future enhancement.

OrKoN commented 3 months ago

@rakuco Thanks! Puppeteer has been historically CDP-only but since some time ago we have WebDriver BiDi support https://pptr.dev/webdriver-bidi The WebDriver BiDi progress can be tracked here https://puppeteer.github.io/ispuppeteerwebdriverbidiready/ Implementation of WebDriver BiDi for Chrome is in https://github.com/GoogleChromeLabs/chromium-bidi which is similarly to chromedriver is a CDP-client but written in TypeScript so it's a bit easier (subjective) to change. The permissions spec could be an example that implements both protocols https://www.w3.org/TR/permissions/#automation-webdriver-bidi