w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
336 stars 35 forks source link

Add formats to `captureScreenshot` #561

Closed jrandolf closed 9 months ago

jrandolf commented 9 months ago

This PR implements screenshot formats.

Closes https://github.com/w3c/webdriver-bidi/issues/383

FAQ

Do implementations need to support all formats?

No, if the implementation is unable to capture a screenshot of a context for any reason, then return error with error code unsupported operation.


Preview | Diff

jrandolf commented 9 months ago

@jgraham @gsnedders PTAL. We internally discussed what formats should be considered. I suggested we use the ones proposed here, but @OrKoN questioned whether they are compatible with other browsers. Considering implementations can throw unsupported operation, I think these should be okay.

Alternatively, we can make this a string and state it must be a image mime type. This is more flexible in case you folks have other requirements such as proprietary formats.

For example,

? format: string | browsingContext.ScreenshotFormat;
...

browsingContext.ScreenshotFormat = {
  type: string
} & Extensible

We could then change the algorithm to allow implementation-specific formats when the format is not one of the predefined types (webp, png, and jpeg).

OrKoN commented 9 months ago

I think if there will be no agreement that we need to support a shared set of the formats, we can probably have a vendor prefixed extension for the screenshot types in chromium-bidi.

OrKoN commented 9 months ago

@jrandolf please link and see comments on https://github.com/w3c/webdriver-bidi/issues/383

jrandolf commented 9 months ago

@gsnedders @jgraham Is it ready to land?

whimboo commented 8 months ago

@jrandolf are you going to add new wpt tests for this feature? CC @OrKoN.

jrandolf commented 8 months ago

Done: https://github.com/web-platform-tests/wpt/pull/42804