You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains 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
2, because the changes are localized to specific functionalities related to user prompt events in a JavaScript codebase. The modifications are straightforward and involve adding new classes and handling logic for these events.
🧪 Relevant tests
Yes
⚡ Possible issues
Possible Bug: The new event handling for 'UserPromptOpened' and 'UserPromptClosed' might not work as expected in Chrome and Edge due to a noted discrepancy in how these browsers handle browsing context IDs. This could lead to failed assertions as noted in the test comments.
Use a switch statement instead of multiple if-else statements for better readability and maintainability
To improve readability and maintainability, consider using a switch statement instead of multiple if-else statements for determining the type of response to create. This will make the code easier to extend in the future.
let response = null
-if ('navigation' in params) {- response = new NavigationInfo(params.context, params.navigation, params.timestamp, params.url)-} else if ('type' in params) {- response = new UserPromptOpened(params.context, params.type, params.message)-} else if ('accepted' in params) {- response = new UserPromptClosed(params.context, params.accepted, params.userText)-} else {- response = new BrowsingContextInfo(params.context, params.url, params.children, params.parent)+switch (true) {+ case 'navigation' in params:+ response = new NavigationInfo(params.context, params.navigation, params.timestamp, params.url)+ break+ case 'type' in params:+ response = new UserPromptOpened(params.context, params.type, params.message)+ break+ case 'accepted' in params:+ response = new UserPromptClosed(params.context, params.accepted, params.userText)+ break+ default:+ response = new BrowsingContextInfo(params.context, params.url, params.children, params.parent)
}
Apply this suggestion
Suggestion importance[1-10]: 7
Why: The suggestion to use a switch statement improves readability and maintainability, making it easier to manage and extend the code. This is a valid improvement for the given context.
7
Possible issue
Add a timeout to the await driver.wait(until.alertIsPresent()) calls to handle potential asynchronous issues
To ensure the test cases are more robust and handle potential asynchronous issues, consider adding a timeout to the await driver.wait(until.alertIsPresent()) calls.
Why: Adding a timeout is a good practice to avoid potential infinite waiting issues in asynchronous operations. This suggestion enhances the robustness of the test cases.
6
Best practice
Add default values for the type and message parameters in the UserPromptOpened constructor
To ensure consistency and avoid potential issues, consider adding default values for the type and message parameters in the UserPromptOpened constructor.
Why: Adding default values for parameters can prevent runtime errors and make the function calls more predictable. However, this is a minor improvement as it depends on the specific use case and requirements.
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.
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.
Description
Add user prompt types for events "UserPromptOpened" and "UserPromptClosed". Else it was defaulting to the wrong type.
Motivation and Context
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
UserPromptOpened
andUserPromptClosed
events inbrowsingContextInspector.js
.UserPromptOpened
andUserPromptClosed
inbrowsingContextTypes.js
.UserPromptOpened
andUserPromptClosed
events inbrowsingcontext_inspector_test.js
.Changes walkthrough 📝
browsingContextInspector.js
Add handling for user prompt events in browsing context inspector
javascript/node/selenium-webdriver/bidi/browsingContextInspector.js
UserPromptOpened
andUserPromptClosed
.UserPromptOpened
andUserPromptClosed
events.browsingContextTypes.js
Define classes for user prompt events
javascript/node/selenium-webdriver/bidi/browsingContextTypes.js
UserPromptOpened
class.UserPromptClosed
class.browsingcontext_inspector_test.js
Add tests for user prompt events in browsing context inspector
javascript/node/selenium-webdriver/test/bidi/browsingcontext_inspector_test.js
UserPromptOpened
event.UserPromptClosed
event.