Skip to content

Commit

Permalink
fix: 将 BrowserConnectOptions 的 protocolType 属性改为 protocol ,同时移除 Launc…
Browse files Browse the repository at this point in the history
…hOptions 的 protocol 属性
  • Loading branch information
fanyong920 committed Dec 24, 2024
1 parent c44a177 commit 2f3dd31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ public class BrowserConnectOptions extends BrowserLaunchArgumentOptions {
*/
private int protocolTimeout = Constant.DEFAULT_TIMEOUT;
/**
* 连接协议
* firefox -- webdriver bidi
* chrome -- cdp
* 使用的通讯协议,CHROME 默认是 CDP,也仅支持 CDP
* <p>
* firefox 默认使用 WebDriverBiDi,也仅支持 WebDriverBiDi
* <p>
* 目前该字段作为保留字段,方便以后支持更多协议
*/
private Protocol protocolType;
private Protocol protocol;

public BrowserConnectOptions() {
super();
Expand Down Expand Up @@ -94,12 +96,12 @@ public void setProtocolTimeout(int protocolTimeout) {
this.protocolTimeout = protocolTimeout;
}

public Protocol getProtocolType() {
return protocolType;
public Protocol getProtocol() {
return protocol;
}

public void setProtocolType(Protocol protocolType) {
this.protocolType = protocolType;
public void setProtocol(Protocol protocol) {
this.protocol = protocol;
}

@Override
Expand All @@ -111,7 +113,7 @@ public String toString() {
", targetFilter=" + targetFilter +
", isPageTarget=" + isPageTarget +
", protocolTimeout=" + protocolTimeout +
", protocolType=" + protocolType +
", protocolType=" + protocol +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ private LaunchOptions(Builder builder) {
this.preferredRevision = builder.preferredRevision;
this.cacheDir = builder.cacheDir;
this.extraPrefsFirefox = builder.extraPrefsFirefox;
this.protocol = builder.protocol;
this.setAcceptInsecureCerts(builder.acceptInsecureCerts);
this.setDefaultViewport(builder.defaultViewport);
this.setSlowMo(builder.slowMo);
Expand All @@ -39,6 +38,7 @@ private LaunchOptions(Builder builder) {
this.setDevtools(builder.devtools);
this.setDebuggingPort(builder.debuggingPort);
this.setTimeout(builder.timeout);
this.setProtocol(builder.protocol);
}

/**
Expand Down Expand Up @@ -108,14 +108,6 @@ private LaunchOptions(Builder builder) {
* {@link <a href="https://searchfox.org/mozilla-release/source/modules/libpref/init/all.js">| Additional preferences</a>} that can be passed when launching with Firefox.
*/
private Map<String, Object> extraPrefsFirefox;
/**
* 使用的通讯协议,CHROME 默认是 CDP,也仅支持 CDP
* <p>
* firefox 默认使用 WebDriverBiDi,也仅支持 WebDriverBiDi
* <p>
* 目前该字段作为保留字段,方便以后支持更多协议
*/
private Protocol protocol;


public static Builder builder() {
Expand Down Expand Up @@ -364,12 +356,4 @@ public Map<String, Object> getExtraPrefsFirefox() {
public void setExtraPrefsFirefox(Map<String, Object> extraPrefsFirefox) {
this.extraPrefsFirefox = extraPrefsFirefox;
}

public Protocol getProtocol() {
return protocol;
}

public void setProtocol(Protocol protocol) {
this.protocol = protocol;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public Browser connect(ConnectOptions options) throws Exception {
} else {
throw new IllegalArgumentException("Exactly one of browserWSEndpoint, browserURL or transport must be passed to puppeteer.connect");
}
if (Objects.equals(options.getProtocolType(), Protocol.WebDriverBiDi)) {
if (Objects.equals(options.getProtocol(), Protocol.WebDriverBiDi)) {
return connectToBiDiBrowse(connectionTransport, endpointUrl, options);
} else {
return connectToCdpBrowser(connectionTransport, endpointUrl, options);
Expand Down

0 comments on commit 2f3dd31

Please sign in to comment.