[rb] Add cross-browser Driver#install_web_extension - #17879
Conversation
…Firefox classic install_addon methods
PR Summary by QodoAdd cross-browser Driver#install_web_extension via BiDi with Firefox fallback
AI Description
Diagram
High-Level Assessment
Files changed (24)
|
Code Review by Qodo
1. devtools raises under BiDi
|
| if @bridge.bidi? | ||
| raise Error::WebDriverError, | ||
| 'CDP (DevTools) is disabled when BiDi is enabled; use the WebDriver BiDi APIs instead' | ||
| end |
There was a problem hiding this comment.
1. devtools raises under bidi 📘 Rule violation ⚙ Maintainability
Calling driver.devtools now raises when @bridge.bidi? is true, which is a user-visible behavior change for BiDi users without an explicit deprecation/migration period. This can break downstream code that previously used CDP while experimenting with BiDi.
Agent Prompt
## Issue description
`Driver#devtools` now raises when BiDi is enabled, which is a breaking user-visible behavior change without an explicit deprecation/migration period.
## Issue Context
The PR introduces a hard failure path (`raise Error::WebDriverError`) for `devtools` when `@bridge.bidi?` is true. To maintain compatibility expectations, provide an explicit deprecation/migration path (or a documented compatibility switch) before enforcing this behavior.
## Fix Focus Areas
- rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb[28-35]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if bidi? | ||
| options['args'] = options['args'].to_a | %w[--enable-unsafe-extension-debugging --remote-debugging-pipe] | ||
| end |
There was a problem hiding this comment.
2. Bidi args nomethoderror 🐞 Bug ☼ Reliability
In Chromium::Options#process_browser_options, when BiDi is enabled it calls options['args'].to_a, which raises NoMethodError if args is a String (or other non-Array) that can be set via Options initialization/merge or add_option. This crashes option processing before session start, instead of producing a clear argument/type error.
Agent Prompt
### Issue description
When BiDi is enabled, Chromium options processing does `options['args'].to_a`, which can raise `NoMethodError` if `args` is not an Array (e.g., a String). This prevents session creation and yields an opaque error.
### Issue Context
`Chromium::Options#initialize` merges defaults with user-supplied `@options`, so `args:` provided as a non-Array can override the default `[]`. `Common::Options#add_option` also stores values without type validation.
### Fix Focus Areas
- rb/lib/selenium/webdriver/chromium/options.rb[227-241]
### Suggested change
- Replace `options['args'].to_a` with safer normalization, e.g.:
- `args = options['args']
args = args.nil? ? [] : Array(args)
options['args'] = args | %w[--enable-unsafe-extension-debugging --remote-debugging-pipe]`
- Alternatively, if you want strictness, explicitly raise a `WebDriverError` when `options['args']` is present and not an `Array`, with a clear message (`'args' must be an Array of Strings`).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
🔗 Related Issues
Prototype implementation for proposed ADR: #17817
This PR will remain in Draft until that proposal is approved
💥 What does this PR do?
Implements the ADR decisions:
Driver#install_web_extensionandDriver#uninstall_web_extension, backed by thegenerated BiDi
webExtensionprotocol classes. Install accepts a directory, packed archive, or base64 bytes(plus Firefox's
permanent/allow_private_browsingoptions) and returns aWebExtensionhandle wrappingthe id; uninstall takes that handle.
moz/addonendpoint), andthe legacy
install_addon/uninstall_addonare deprecated toward the new methods — no routing.--remote-debugging-pipeand--enable-unsafe-extension-debugging(no user flags), and Selenium's CDP API raises while BiDi is on.over BiDi or the classic endpoint.
install_addon/uninstall_addonnow emit a deprecation warning.to the pipe transport and allows unsigned extensions with no user flags.
"enable BiDi" error rather than a
NoMethodError. On Firefox,allow_private_browsing: falsealso raises,since the classic endpoint always grants private-browsing access and cannot disable it.
🔧 Implementation Notes
encode_extension) lives on the base bridge: it zips a directory, base64-encodes a file, orpasses base64 through. Both the base BiDi path and
Firefox::Featuresuse it;Firefox::Featuresbrancheson
bidi?— BiDi uses themozvendor variant, classic uses themoz/addonendpoint.archivePath,so Chromium can only install an unpacked directory whose path resolves on the browser host (local sessions)
— no packed archive, no Grid. A temporary
Chromium::Featuresoverride sends that directory path directly;it is removed once chromium-bidi supports base64 ([🐛 Bug]: [python][Chrome] Webextension - no support for archived and base64 extensionData type in Chrome? #16541), at which point Chromium picks up archive/base64/Grid
support with no API change.
bidi,connection,web_extension,install_web_extension,uninstall_web_extension) share a single "enable BiDi" raiser via aliases, so a browser with no classicpath gets the same error everywhere.
🤖 AI assistance
💡 Additional Considerations
decisions process implementing PRs land after acceptance and are linked from the ADR tracking issue.
temporary override is removed then.
🔄 Types of changes