Enable Support for WebDriver-Bidi in Firefox#619
Conversation
cdbe8d6 to
8b5a2a5
Compare
gregberge
left a comment
There was a problem hiding this comment.
I don't understand the concept of this PR sorry. We are now disconnecting all browsers instantely and we connect / disconnect into the close browsers function. Something is not clear to me.
| ); | ||
| const wsEndpoints = browsers.map((browser) => browser.wsEndpoint()); | ||
| saveWsEndpoints(wsEndpoints); | ||
| browsers.forEach((browser) => browser.disconnect()); |
| while (wsEndpoints.length) { | ||
| const wsEndpoint = wsEndpoints.pop()!; | ||
| closeRequests.push( | ||
| puppeteer | ||
| .connect({ | ||
| ...(config.launch?.browser === "firefox" && { | ||
| protocol: "webDriverBiDi", | ||
| }), | ||
| ...config.connect, | ||
| ...config.launch, | ||
| browserURL: undefined, | ||
| browserWSEndpoint: wsEndpoint, | ||
| }) | ||
| .then((browser) => browser.close()), | ||
| ); | ||
| } |
There was a problem hiding this comment.
Can you just do a map instead of doing a loop like that?
| ...(config.launch?.browser === "firefox" && { | ||
| protocol: "webDriverBiDi", | ||
| }), |
| puppeteer | ||
| .connect({ |
There was a problem hiding this comment.
Why are we connecting into the closeBrowsers
|
@gregberge I decided to reply here rather than in-line as you may prefer an alternative approach. Firefox 141+ no longer works because it dropped supported for CDP (puppeteer also remove CDP support for Firefox) and it does not support multiple connections over WebDriver BiDi (CDP did). The easiest way to re-enable support for Firefox is to first launch the browser and record the wsEndpoint. We have to disconnect after the initial setup as other connections are made during jest-puppeteer/packages/jest-environment-puppeteer/src/browsers.ts Lines 125 to 136 in ddb3fb9 This will throw in firefox. See #609. I suppose an alternative (and cleaner) fix here would be to return the existing browser instance from |
|
@gregberge Just following up on this. Is there one approach you'd prefer over the other? |
Summary
Closes #609.
Support for CDP was removed in Firefox v141, leaving WebDriver BiDi as the only supported automation protocol. However, Firefox currently does not support multiple concurrent WebDriver BiDi sessions.
To work around this limitation, the setup has been modified to:
wsEndpointSubsequent access to the browser is handled via
puppeteer.connect()using the savedwsEndpoint, ensuring only a single active connection at any time.Test Plan
Firefox-specific tests were added and can be run via the
test:firefoxnpm script.