Enable BiDi support for connect-existing mode#50
Open
MayCXC wants to merge 1 commit intomozilla:mainfrom
Open
Conversation
GeckodriverHttpDriver now requests webSocketUrl: true in the session capabilities and exposes a getBidi() method that opens a WebSocket to Firefox's Remote Agent. This allows BiDi-dependent features (console events, network events) to work when using --connect-existing. The WebSocket is opened lazily on the first getBidi() call and closed on quit/kill. The IBiDi interface already defined upstream is satisfied by wrapping the ws WebSocket instance. No behavior change for launch mode (continues to use selenium-webdriver with enableBidi). No behavior change for connect-existing when Firefox was not started with --remote-debugging-port (getBidi throws a clear error, same as before but with a better message).
1b0f461 to
fcd5855
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #45 (rebased on current main).
Summary
--connect-existingmode currently disables all BiDi-dependent features (console events, network events) becauseselenium-webdriver'screateSession()hangs when trying to auto-upgrade to BiDi with an existing Firefox instance.This PR enables BiDi by:
webSocketUrl: truein the session capabilities sent to geckodriverwebSocketUrlfrom the session response (set by Firefox's Remote Agent)getBidi()onGeckodriverHttpDriverthat opens a WebSocket to that URL, satisfying theIBiDiinterface already defined upstreamThe existing
hasBidicheck ('getBidi' in driver) naturally picks up the new method, so console and network event collection work without further changes.Behavior
selenium-webdriverwithenableBidi().--remote-debugging-port: BiDi features (console, network) now work.--remote-debugging-port:getBidi()throws a clear error. All non-BiDi features continue to work as before.Changes
src/firefox/core.ts: 45 insertions, 6 deletions (all inGeckodriverHttpDriver)Test plan
tsc --noEmitpassesbun run buildsucceeds--connect-existingwith Firefox started with--marionette --remote-debugging-port 9222, verifiedlist_console_messagesandlist_network_requestsreturn data