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

[rb] Deprecate CDP methods on Firefox #14763

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

aguspe
Copy link
Contributor

@aguspe aguspe commented Nov 15, 2024

Description

This PR adds deprecation warnings for all the CDP methods for Firefox

Example of deprecation warnings:

Screenshot 2024-11-15 at 23 39 53 Screenshot 2024-11-15 at 23 37 14

Motivation and Context

Based on https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/

We want to deprecate CDP methods on firefox and encourage Selenium users to use the new BiDi implementation

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Code Consistency
Verify that the deprecation warning is shown only when Firefox is actually being used, and that the browser variable is properly set and accessible

Error Handling
Consider adding error handling for cases where BiDi implementation is not available as an alternative

Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
Performance
Cache deprecation warning status to improve performance on repeated method calls

Consider memoizing the deprecation warning check to avoid repeated evaluations when
the intercept method is called multiple times.

rb/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb [63-69]

-if browser == :firefox
-  WebDriver.logger.deprecate(
-    'Driver#intercept on Firefox',
-    'the new BiDi implementation',
-    id: :intercept
-  )
+@firefox_deprecation_shown ||= begin
+  if browser == :firefox
+    WebDriver.logger.deprecate(
+      'Driver#intercept on Firefox',
+      'the new BiDi implementation',
+      id: :intercept
+    )
+  end
 end
  • Apply this suggestion
Suggestion importance[1-10]: 7

Why: Memoizing the deprecation warning is a good optimization that prevents showing the same warning multiple times, improving both user experience and performance when the intercept method is called repeatedly.

7
Possible bug
Add a safety check for undefined variables to prevent potential runtime errors

Consider checking if browser is defined before using it. Add a guard clause to
handle cases where the browser type might be undefined.

rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb [31-37]

-if browser == :firefox
+if defined?(browser) && browser == :firefox
   WebDriver.logger.deprecate(
     'Driver#devtools on Firefox',
     'the new BiDi implementation',
     id: :devtools
   )
 end
  • Apply this suggestion
Suggestion importance[1-10]: 3

Why: While adding a check for defined?(browser) could prevent potential errors, it's likely unnecessary as 'browser' is probably an instance method defined in a parent class. The suggestion is overly cautious.

3

💡 Need additional feedback ? start a PR chat

@aguspe aguspe self-assigned this Nov 15, 2024
Copy link
Member

@p0deje p0deje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should provide a replacement implementation and mention it in deprecation.

For example,on_log_event should be deprecated in favor of script.add_console_message_handler / script.add_javascript_error_handler.

If we don't have exact replacements yet, I suggest we hold off deprecating the methods (suggestion per https://seleniumhq.slack.com/archives/CBH302726/p1731796745420569?thread_ts=1731576590.042029&cid=CBH302726).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants