-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
[java] Prevent accessing BiDi internals from driver #17745
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| import java.util.function.Consumer; | ||
| import java.util.logging.Logger; | ||
| import org.openqa.selenium.Beta; | ||
| import org.openqa.selenium.WebDriver; | ||
| import org.openqa.selenium.WebDriverException; | ||
| import org.openqa.selenium.internal.Require; | ||
|
|
||
|
|
@@ -40,6 +41,16 @@ public class BiDi implements Closeable { | |
| private final Connection connection; | ||
| private final Map<Event<?>, List<Long>> contextListenerIds = new ConcurrentHashMap<>(); | ||
|
|
||
| public static BiDi from(WebDriver driver) { | ||
| Require.nonNull("WebDriver", driver); | ||
| if (!(driver instanceof HasBiDi)) { | ||
| throw new BiDiException("WebDriver does not support BiDi protocol"); | ||
| } | ||
| return ((HasBiDi) driver) | ||
| .maybeGetBiDi() | ||
| .orElseThrow(() -> new BiDiException("Unable to create a BiDi connection")); | ||
| } | ||
|
Comment on lines
+44
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Bidi.from skips initialization BiDi.from(WebDriver) calls HasBiDi.maybeGetBiDi() and throws when it’s empty, but the BiDi augmenter (BiDiProvider) intentionally keeps BiDi lazy and returns Optional.empty until getBiDi() is called. This makes BiDi.from() fail on freshly augmented RemoteWebDriver instances, breaking RemoteWebDriver.script()/RemoteScript and the updated RemoteWebDriverBiDiTest path. Agent Prompt
|
||
|
|
||
| /** | ||
| * @deprecated Use constructor with timeout parameter: {@link #BiDi(Connection, Duration)} | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,15 @@ | |
|
|
||
| import java.util.Optional; | ||
| import org.openqa.selenium.Beta; | ||
| import org.openqa.selenium.WebDriver; | ||
|
|
||
| @Beta | ||
| public interface HasBiDi { | ||
|
|
||
| /** | ||
| * @deprecated Use {@link BiDi#from(WebDriver)} instead. | ||
| */ | ||
| @Deprecated(since = "4.24", forRemoval = true) | ||
| default BiDi getBiDi() { | ||
| return maybeGetBiDi() | ||
| .orElseThrow(() -> new BiDiException("Unable to create a BiDi connection")); | ||
|
Comment on lines
+27
to
33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. hasbidi.getbidi() javadoc incomplete The modified (deprecated) public method HasBiDi.getBiDi() has Javadoc consisting only of an @deprecated tag and omits an @return tag. This violates the requirement for complete Javadoc on touched public methods. Agent Prompt
|
||
|
|
||
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.
1. bidi.from() missing javadoc
📘 Rule violation✧ QualityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools