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
Deprecated Class The class ArgumentValue is deprecated and replaced by direct usage of LocalValue methods. Ensure that all references and dependencies are updated accordingly to prevent future maintenance issues.
Method Addition New methods createReferenceValue and asMap are added to LocalValue. Review for consistency and correctness in implementation, especially in how asMap constructs the return object.
Add error handling in createReferenceValue to ensure input validity
Add error handling in createReferenceValue to ensure that both handle and sharedId are valid before creating a new ReferenceValue. This can prevent potential runtime errors due to invalid inputs.
static createReferenceValue(handle, sharedId) {
+ if (!handle || !sharedId) {+ throw new Error('Invalid handle or sharedId for creating ReferenceValue');+ }
return new ReferenceValue(handle, sharedId)
Apply this suggestion
Suggestion importance[1-10]: 9
Why: Adding error handling to ensure that both handle and sharedId are valid before creating a new ReferenceValue is crucial for preventing potential runtime errors, thus improving the robustness of the code.
9
Enhancement
Remove the asMap method from ArgumentValue to enforce the use of LocalValue
Since ArgumentValue is deprecated and its functionality is being replaced by LocalValue, consider removing the asMap method from ArgumentValue to prevent its usage and enforce migration to LocalValue.
-asMap() {- if (this.value instanceof LocalValue) {- return this.value.asMap()- } else {- // ReferenceValue- return this.value.asMap()+// asMap method removed to enforce using LocalValue directly
Apply this suggestion
Suggestion importance[1-10]: 8
Why: Removing the asMap method from a deprecated class enforces the migration to the new LocalValue class, which is a significant improvement in maintaining code consistency and preventing the use of deprecated functionality.
8
Add a deprecation warning in the ArgumentValue constructor
Since the ArgumentValue class is deprecated, consider adding a console warning in the constructor to inform developers about its deprecation when an instance is created.
constructor(value) {
+ console.warn('ArgumentValue is deprecated. Use LocalValue directly.');
this.value = value
Apply this suggestion
Suggestion importance[1-10]: 7
Why: Adding a console warning in the constructor of a deprecated class informs developers about its deprecation, which is a helpful enhancement for maintaining code quality and guiding developers towards using the recommended class.
7
Possible issue
Add error handling for undefined type in asMap to improve method robustness
Consider adding a default case or error handling in asMap to manage unexpected type values gracefully, which can improve the robustness of the method.
asMap() {
let toReturn = {}
+ if (!this.type) {+ throw new Error('Undefined type in LocalValue');+ }
toReturn[TYPE_CONSTANT] = this.type
Apply this suggestion
Suggestion importance[1-10]: 8
Why: Adding error handling for undefined type values in the asMap method improves the robustness and reliability of the method, ensuring that unexpected values are managed gracefully.
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
Motivation and Context
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
ArgumentValue
class in favor of usingLocalValue
methods directly.createReferenceValue
to theLocalValue
class.toJson
method toasMap
in theLocalValue
class.ArgumentValue
class and useLocalValue
directly.LocalValue
.Changes walkthrough 📝
argumentValue.js
Deprecate `ArgumentValue` class and update `asMap` method
javascript/node/selenium-webdriver/bidi/argumentValue.js
ArgumentValue
class.asMap
method to useLocalValue
.protocolValue.js
Add `createReferenceValue` method and rename `toJson` to `asMap`
javascript/node/selenium-webdriver/bidi/protocolValue.js
createReferenceValue
static method.toJson
method toasMap
.script.js
Remove `ArgumentValue` import and use `LocalValue` directly
javascript/node/selenium-webdriver/lib/script.js
ArgumentValue
import.LocalValue
directly.local_value_test.js
Update tests to use `LocalValue` directly
javascript/node/selenium-webdriver/test/bidi/local_value_test.js
ArgumentValue
import.LocalValue
directly.locate_nodes_test.js
Update locate nodes tests to use `LocalValue` directly
javascript/node/selenium-webdriver/test/bidi/locate_nodes_test.js
ArgumentValue
import.LocalValue
directly.script_test.js
Update script tests to use `LocalValue` directly
javascript/node/selenium-webdriver/test/bidi/script_test.js
ArgumentValue
import.LocalValue
directly.