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

[java] do not enable CDP deprecation warning if BiDi enabled #15170

Merged
merged 6 commits into from
Jan 31, 2025

Conversation

Delta456
Copy link
Contributor

@Delta456 Delta456 commented Jan 27, 2025

User description

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Fixes #11736 (comment)

Motivation and Context

It adds if BiDi is enabled then do not show the CDP warning.

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.

PR Type

Enhancement, Bug fix


Description

  • Suppress CDP deprecation warning if BiDi is enabled.

  • Adjusted logic for Firefox CDP deprecation warnings.

  • Improved compatibility with WebDriver BiDi protocol.


Changes walkthrough 📝

Relevant files
Enhancement
CdpEndpointFinder.java
Adjust CDP deprecation warning logic for Firefox                 

java/src/org/openqa/selenium/devtools/CdpEndpointFinder.java

  • Added condition to suppress CDP warning if webSocketUrl is enabled.
  • Refined deprecation warning logic for Firefox.
  • +5/-3     
    Bug fix
    FirefoxDriver.java
    Update FirefoxDriver to respect BiDi capability                   

    java/src/org/openqa/selenium/firefox/FirefoxDriver.java

  • Modified CDP warning logic to check webSocketUrl capability.
  • Ensured warnings are only shown when BiDi is not enabled.
  • +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis 🔶

    11736 - Partially compliant

    Compliant requirements:

    • Deprecate CDP support for Firefox for at least 2 versions before complete removal

    Non-compliant requirements:

    • Remove CDP support for Firefox browser

    Requires further human verification:

    • Verify that the warning message is displayed correctly in real Firefox browser sessions
    • Validate that BiDi functionality works as expected when enabled
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Null Safety

    The capability check '(Boolean) capabilities.getCapability("webSocketUrl")' might throw ClassCastException if the value is not Boolean, or NullPointerException if the capability is not present

    if (reportedUri.isPresent() && !(Boolean) capabilities.getCapability("webSocketUrl")) {
    Null Safety

    The capability check '(Boolean) caps.getCapability("webSocketUrl")' might throw ClassCastException if the value is not Boolean, or NullPointerException if the capability is not present

    if (!(Boolean) caps.getCapability("webSocketUrl")) {

    Copy link
    Contributor

    qodo-merge-pro bot commented Jan 27, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    ✅ Add null check for capability
    Suggestion Impact:The commit addresses the same issue by using caps.is() method instead of direct casting, which safely handles null values

    code diff:

    -        if (!(Boolean) caps.getCapability("webSocketUrl")) {
    +        if (!caps.is("webSocketUrl")) {

    Add null check for 'webSocketUrl' capability to prevent NullPointerException when
    casting to Boolean

    java/src/org/openqa/selenium/devtools/CdpEndpointFinder.java [94]

    -if (!(Boolean) caps.getCapability("webSocketUrl")) {
    +if (caps.getCapability("webSocketUrl") == null || !(Boolean) caps.getCapability("webSocketUrl")) {
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: The suggestion addresses a critical potential NullPointerException that could occur when casting a null capability value to Boolean. This is a significant safety improvement that prevents runtime crashes.

    9

    @Delta456 Delta456 requested a review from diemol January 30, 2025 09:44
    @pujagani pujagani merged commit 9449b58 into SeleniumHQ:trunk Jan 31, 2025
    4 checks passed
    @Delta456 Delta456 deleted the firefox_cdp_warn branch January 31, 2025 08:05
    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.

    [🚀 Feature]: Remove CDP support for Firefox browser
    4 participants