Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

rakuco
Copy link
Member

@rakuco rakuco commented Jun 14, 2024

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:

  • Shared workers are unsupported at the moment (i.e. the WebDriver endpoints
    only have an effect on Window and DedicaredWorkerGlobalScope globals).
    Storing virtual pressure source information in a top-level traversable
    does not play well with shared workers, for which the concept is somewhat
    irrelevant.
    We need to think of a different solution in the future if support for
    shared workers is important.
  • Once PressureObserver.observe() resolves, the same platform collector
    will be used until disconnect() or unobserve() are called. In other
    words, if a PressureObserver instance is active and using a real pressure
    source, adding a virtual pressure source of the same type will only have
    an effect on it and other instances in the same global once they all
    disconnect from the existing pressure source first.

In terms of changes to the existing algorithms and concepts:

  • A top-level traversable has a mapping of source types to virtual pressure
    sources that is manipulated by the WebDriver endpoints.
  • When creating a new platform collector, PressureObserver.observe() first
    attempts to use a virtual pressure source when one exists and can be used.
  • The data collection algorithm distinguishes between the data format used
    by a virtual pressure source (which already is a PressureState) and by a
    real pressure source (which needs to be transformed into a PressureState).

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

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:
- Shared workers are unsupported at the moment (i.e. the WebDriver endpoints
  only have an effect on Window and DedicaredWorkerGlobalScope globals).
  Storing virtual pressure source information in a top-level traversable
  does not play well with shared workers, for which the concept is somewhat
  irrelevant.
  We need to think of a different solution in the future if support for
  shared workers is important.
- Once `PressureObserver.observe()` resolves, the same platform collector
  will be used until `disconnect()` or `unobserve()` are called. In other
  words, if a PressureObserver instance is active and using a real pressure
  source, adding a virtual pressure source of the same type will only have
  an effect on it and other instances in the same global once they all
  disconnect from the existing pressure source first.

In terms of changes to the existing algorithms and concepts:
- A top-level traversable has a mapping of source types to virtual pressure
  sources that is manipulated by the WebDriver endpoints.
- When creating a new platform collector, `PressureObserver.observe()` first
  attempts to use a virtual pressure source when one exists and can be used.
- The data collection algorithm distinguishes between the data format used
  by a virtual pressure source (which already is a PressureState) and by a
  real pressure source (which needs to be transformed into a PressureState).

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.
@rakuco rakuco requested review from kenchris and arskama June 14, 2024 12:28
@rakuco
Copy link
Member Author

rakuco commented Jun 14, 2024

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

@rakuco rakuco merged commit afd4b36 into main Jun 14, 2024
2 checks passed
@rakuco rakuco deleted the add-webdriver-support branch June 14, 2024 13:03
arskama added a commit to arskama/compute-pressure that referenced this pull request Jun 14, 2024
Adding Raphael after his large contribution.

Clarification in specification: w3c#283
Automation section: w3c#284
anssiko pushed a commit that referenced this pull request Jun 17, 2024
Adding Raphael as an editor. Some of his recent contributions include:

Clarification in specification: #283
Automation section: #284
@OrKoN
Copy link

OrKoN commented Jun 20, 2024

@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).

@rakuco
Copy link
Member Author

rakuco commented Jun 20, 2024

@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
Copy link

OrKoN commented Jun 20, 2024

@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
Copy link
Member Author

rakuco commented Jun 20, 2024

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
Copy link

OrKoN commented Jun 20, 2024

@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

JuhaVainio added a commit to JuhaVainio/WPT that referenced this pull request Sep 9, 2024
Spec PR: w3c/compute-pressure#284

This PR adds the required infrastructure to manipulate compute pressure
from testdriver. The three new commands correspond to the three
WebDriver extension commands added by the spec PR above.
past pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 16, 2024
* Add compute pressure-related commands to testdriver

Spec PR: w3c/compute-pressure#284

This PR adds the required infrastructure to manipulate compute pressure
from testdriver. The three new commands correspond to the three
WebDriver extension commands added by the spec PR above.

* Change the specification reference from "virtual pressure sample" to "virtual pressure state"
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 25, 2024
… testdriver, a=testonly

Automatic update from web-platform-tests
Add compute pressure-related commands to testdriver (#48035)

* Add compute pressure-related commands to testdriver

Spec PR: w3c/compute-pressure#284

This PR adds the required infrastructure to manipulate compute pressure
from testdriver. The three new commands correspond to the three
WebDriver extension commands added by the spec PR above.

* Change the specification reference from "virtual pressure sample" to "virtual pressure state"
--

wpt-commits: 384f5d9f4d9dccecb3374990ffdc9b3e181d5ff5
wpt-pr: 48035
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Sep 26, 2024
… testdriver, a=testonly

Automatic update from web-platform-tests
Add compute pressure-related commands to testdriver (#48035)

* Add compute pressure-related commands to testdriver

Spec PR: w3c/compute-pressure#284

This PR adds the required infrastructure to manipulate compute pressure
from testdriver. The three new commands correspond to the three
WebDriver extension commands added by the spec PR above.

* Change the specification reference from "virtual pressure sample" to "virtual pressure state"
--

wpt-commits: 384f5d9f4d9dccecb3374990ffdc9b3e181d5ff5
wpt-pr: 48035

UltraBlame original commit: 54f6c255d0ae66171bdce4ad7945d0154168f51a
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Sep 26, 2024
… testdriver, a=testonly

Automatic update from web-platform-tests
Add compute pressure-related commands to testdriver (#48035)

* Add compute pressure-related commands to testdriver

Spec PR: w3c/compute-pressure#284

This PR adds the required infrastructure to manipulate compute pressure
from testdriver. The three new commands correspond to the three
WebDriver extension commands added by the spec PR above.

* Change the specification reference from "virtual pressure sample" to "virtual pressure state"
--

wpt-commits: 384f5d9f4d9dccecb3374990ffdc9b3e181d5ff5
wpt-pr: 48035

UltraBlame original commit: 54f6c255d0ae66171bdce4ad7945d0154168f51a
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Sep 26, 2024
… testdriver, a=testonly

Automatic update from web-platform-tests
Add compute pressure-related commands to testdriver (#48035)

* Add compute pressure-related commands to testdriver

Spec PR: w3c/compute-pressure#284

This PR adds the required infrastructure to manipulate compute pressure
from testdriver. The three new commands correspond to the three
WebDriver extension commands added by the spec PR above.

* Change the specification reference from "virtual pressure sample" to "virtual pressure state"
--

wpt-commits: 384f5d9f4d9dccecb3374990ffdc9b3e181d5ff5
wpt-pr: 48035

UltraBlame original commit: 54f6c255d0ae66171bdce4ad7945d0154168f51a
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Sep 26, 2024
… testdriver, a=testonly

Automatic update from web-platform-tests
Add compute pressure-related commands to testdriver (#48035)

* Add compute pressure-related commands to testdriver

Spec PR: w3c/compute-pressure#284

This PR adds the required infrastructure to manipulate compute pressure
from testdriver. The three new commands correspond to the three
WebDriver extension commands added by the spec PR above.

* Change the specification reference from "virtual pressure sample" to "virtual pressure state"
--

wpt-commits: 384f5d9f4d9dccecb3374990ffdc9b3e181d5ff5
wpt-pr: 48035
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Sep 27, 2024
… testdriver, a=testonly

Automatic update from web-platform-tests
Add compute pressure-related commands to testdriver (#48035)

* Add compute pressure-related commands to testdriver

Spec PR: w3c/compute-pressure#284

This PR adds the required infrastructure to manipulate compute pressure
from testdriver. The three new commands correspond to the three
WebDriver extension commands added by the spec PR above.

* Change the specification reference from "virtual pressure sample" to "virtual pressure state"
--

wpt-commits: 384f5d9f4d9dccecb3374990ffdc9b3e181d5ff5
wpt-pr: 48035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add WebDriver support
4 participants