-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
validate-browsing-context-id #12678
validate-browsing-context-id #12678
Conversation
Enhanced the BrowsingContext Constructor to Include Additional Validation for 'id' Parameter **Hello Selenium community! Your contribution matters and well-described pull requests make reviews and merges efficient. Thank you for your effort!** Before submitting your pull request, please review our [contributing guidelines](https://github.com/SeleniumHQ/selenium/blob/trunk/CONTRIBUTING.md). Keeping pull requests concise and focused helps reviewers. <!--- Provide a general summary of your changes in the Title above --> ### Description In this pull request, I've enhanced the `BrowsingContext` constructor to include additional validation for the 'id' parameter. The objective is to ensure that the 'id' parameter is not only non-null but also non-empty, providing an extra layer of validation. Additionally, I've introduced a validation step to confirm that the WebDriver instance supports the BiDi protocol before retrieving the BiDi instance. ### Motivation and Context This enhancement was motivated by the need to strengthen the validation process for the 'id' parameter in the `BrowsingContext` constructor. By introducing a check for empty string values, we ensure that the 'id' parameter is not only non-null but also contains meaningful content. Additionally, verifying the support for the BiDi protocol in the WebDriver instance helps prevent compatibility issues. ### Types of Changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ### Checklist <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have read the [contributing guidelines](https://github.com/SeleniumHQ/selenium/blob/trunk/CONTRIBUTING.md). - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [] I have added tests to cover my changes. - [x] All new and existing tests passed.
@pujagani, does this make sense? |
In this commit, the LogEntryUtils interface is introduced to centralize the JSON deserialization logic for log entries. This helps eliminate code duplication in the GenericLogEntry and JavascriptLogEntry classes. The LogEntryUtils interface provides a common method for parsing JSON input into log entry objects. Additionally, a new test class, LogEntryUtilsTest, has been created to test the functionality of the LogEntryUtils interface. The JsonInputFactory class is utilized to create JsonInput instances consistently across tests.
Codecov ReportAll modified lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## trunk #12678 +/- ##
=======================================
Coverage 56.51% 56.51%
=======================================
Files 86 86
Lines 5255 5255
Branches 187 187
=======================================
Hits 2970 2970
Misses 2098 2098
Partials 187 187 ☔ View full report in Codecov by Sentry. |
@@ -77,6 +77,10 @@ public BrowsingContext(WebDriver driver, String id) { | |||
throw new IllegalArgumentException("WebDriver instance must support BiDi protocol"); | |||
} | |||
|
|||
if (id.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a good idea to use "Require.precondition" to check for null and empty string.
public static void precondition(boolean condition, String message, Object... args) { |
@manuelsblanco I appreciate your help here. I agree with the motivation stated. However, I see two unrelated changes (motivation-wise) in the same PR. Can you please help split it up? Even if the change is small. It will be easier to review and land them independently. Thank you! |
Sure thing, I'll do this split as soon as possible. |
Hi @pujagani, I have just implemented your suggestion regarding the use of Require.Precondition. Please let me know if there is anything else I can do. |
Thank you for incorporating the changes. Can you please help split up the PR as well? Thank you! |
…mment) Using Require.precondition()
- Created the `LogEntryUtils` interface to centralize common JSON parsing and conversion methods. - Moved the `JsonMap` method to the `BaseLogEntry` class so it can be shared by its subclasses. - Implemented the `toJson()` method in the `JavascriptLogEntry` and `GenericLogEntry` classes. - Updated the `fromJson()` method in the `LogEntryUtils` interface to handle different log entry types. These changes improve code organization and maintainability by centralizing JSON-related functionality in the `LogEntryUtils` interface and reducing code duplication in log entry classes. As requested by @pujagani SeleniumHQ#12678 (comment)
This PR was split in two, we can close this one now. |
Enhanced the BrowsingContext Constructor to Include Additional Validation for 'id' Parameter
Hello Selenium community! Your contribution matters and well-described pull requests make reviews and merges efficient. Thank you for your effort!
Before submitting your pull request, please review our contributing guidelines. Keeping pull requests concise and focused helps reviewers.
Description
In this pull request, I've enhanced the
BrowsingContext
constructor to include additional validation for the 'id' parameter. The objective is to ensure that the 'id' parameter is not only non-null but also non-empty, providing an extra layer of validation. Additionally, I've introduced a validation step to confirm that the WebDriver instance supports the BiDi protocol before retrieving the BiDi instance.Motivation and Context
This enhancement was motivated by the need to strengthen the validation process for the 'id' parameter in the
BrowsingContext
constructor. By introducing a check for empty string values, we ensure that the 'id' parameter is not only non-null but also contains meaningful content. Additionally, verifying the support for the BiDi protocol in the WebDriver instance helps prevent compatibility issues.Types of Changes
Checklist