Skip to content

Commit

Permalink
[java] add cdp v106 remove v103
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Sep 28, 2022
1 parent 697c717 commit 2a05eb1
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ JAVA_RELEASE_TARGETS = %w[
//java/src/org/openqa/selenium/chrome:chrome.publish
//java/src/org/openqa/selenium/chromium:chromium.publish
//java/src/org/openqa/selenium/devtools/v85:v85.publish
//java/src/org/openqa/selenium/devtools/v103:v103.publish
//java/src/org/openqa/selenium/devtools/v104:v104.publish
//java/src/org/openqa/selenium/devtools/v105:v105.publish
//java/src/org/openqa/selenium/devtools/v106:v106.publish
//java/src/org/openqa/selenium/edge:edge.publish
//java/src/org/openqa/selenium/firefox:firefox.publish
//java/src/org/openqa/selenium/grid/sessionmap/jdbc:jdbc.publish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("//common:defs.bzl", "copy_file")
load("//java:defs.bzl", "java_export", "java_library")
load("//java:version.bzl", "SE_VERSION")

cdp_version = "v103"
cdp_version = "v106"

java_export(
name = cdp_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.devtools.v103;
package org.openqa.selenium.devtools.v106;

import com.google.auto.service.AutoService;

import org.openqa.selenium.devtools.CdpInfo;
import org.openqa.selenium.devtools.v106.V106Domains;

@AutoService(CdpInfo.class)
public class V103CdpInfo extends CdpInfo {
public class V106CdpInfo extends CdpInfo {

public V103CdpInfo() {
super(103, V103Domains::new);
public V106CdpInfo() {
super(106, V106Domains::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.devtools.v103;
package org.openqa.selenium.devtools.v106;

import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.idealized.Domains;
Expand All @@ -24,23 +24,28 @@
import org.openqa.selenium.devtools.idealized.Network;
import org.openqa.selenium.devtools.idealized.log.Log;
import org.openqa.selenium.devtools.idealized.target.Target;
import org.openqa.selenium.devtools.v106.V106Events;
import org.openqa.selenium.devtools.v106.V106Javascript;
import org.openqa.selenium.devtools.v106.V106Log;
import org.openqa.selenium.devtools.v106.V106Network;
import org.openqa.selenium.devtools.v106.V106Target;
import org.openqa.selenium.internal.Require;

public class V103Domains implements Domains {
public class V106Domains implements Domains {

private final V103Javascript js;
private final V103Events events;
private final V103Log log;
private final V103Network network;
private final V103Target target;
private final V106Javascript js;
private final V106Events events;
private final V106Log log;
private final V106Network network;
private final V106Target target;

public V103Domains(DevTools devtools) {
public V106Domains(DevTools devtools) {
Require.nonNull("DevTools", devtools);
events = new V103Events(devtools);
js = new V103Javascript(devtools);
log = new V103Log();
network = new V103Network(devtools);
target = new V103Target();
events = new V106Events(devtools);
js = new V106Javascript(devtools);
log = new V106Log();
network = new V106Network(devtools);
target = new V106Target();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,29 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.devtools.v103;
package org.openqa.selenium.devtools.v106;

import com.google.common.collect.ImmutableList;

import org.openqa.selenium.JavascriptException;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.events.ConsoleEvent;
import org.openqa.selenium.devtools.idealized.Events;
import org.openqa.selenium.devtools.idealized.runtime.model.RemoteObject;
import org.openqa.selenium.devtools.v103.runtime.Runtime;
import org.openqa.selenium.devtools.v103.runtime.model.ConsoleAPICalled;
import org.openqa.selenium.devtools.v103.runtime.model.ExceptionDetails;
import org.openqa.selenium.devtools.v103.runtime.model.ExceptionThrown;
import org.openqa.selenium.devtools.v103.runtime.model.StackTrace;
import org.openqa.selenium.devtools.v106.runtime.Runtime;
import org.openqa.selenium.devtools.v106.runtime.model.ConsoleAPICalled;
import org.openqa.selenium.devtools.v106.runtime.model.ExceptionDetails;
import org.openqa.selenium.devtools.v106.runtime.model.ExceptionThrown;
import org.openqa.selenium.devtools.v106.runtime.model.StackTrace;

import java.time.Instant;
import java.util.List;
import java.util.Optional;

public class V103Events extends Events<ConsoleAPICalled, ExceptionThrown> {
public class V106Events extends Events<ConsoleAPICalled, ExceptionThrown> {

public V103Events(DevTools devtools) {
public V106Events(DevTools devtools) {
super(devtools);
}

Expand Down Expand Up @@ -82,7 +81,7 @@ protected ConsoleEvent toConsoleEvent(ConsoleAPICalled event) {
protected JavascriptException toJsException(ExceptionThrown event) {
ExceptionDetails details = event.getExceptionDetails();
Optional<StackTrace> maybeTrace = details.getStackTrace();
Optional<org.openqa.selenium.devtools.v103.runtime.model.RemoteObject>
Optional<org.openqa.selenium.devtools.v106.runtime.model.RemoteObject>
maybeException = details.getException();

String message = maybeException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.devtools.v103;
package org.openqa.selenium.devtools.v106;

import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.idealized.Javascript;
import org.openqa.selenium.devtools.v103.page.Page;
import org.openqa.selenium.devtools.v103.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v103.runtime.Runtime;
import org.openqa.selenium.devtools.v103.runtime.model.BindingCalled;
import org.openqa.selenium.devtools.v106.page.Page;
import org.openqa.selenium.devtools.v106.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v106.runtime.Runtime;
import org.openqa.selenium.devtools.v106.runtime.model.BindingCalled;

import java.util.Optional;

public class V103Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
public class V106Javascript extends Javascript<ScriptIdentifier, BindingCalled> {

public V103Javascript(DevTools devtools) {
public V106Javascript(DevTools devtools) {
super(devtools);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.devtools.v103;
package org.openqa.selenium.devtools.v106;

import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.ConverterFunctions;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.v103.log.Log;
import org.openqa.selenium.devtools.v103.log.model.LogEntry;
import org.openqa.selenium.devtools.v103.runtime.model.Timestamp;
import org.openqa.selenium.devtools.v106.log.Log;
import org.openqa.selenium.devtools.v106.log.model.LogEntry;
import org.openqa.selenium.devtools.v106.runtime.model.Timestamp;
import org.openqa.selenium.json.JsonInput;

import java.util.function.Function;
import java.util.logging.Level;

public class V103Log implements org.openqa.selenium.devtools.idealized.log.Log {
public class V106Log implements org.openqa.selenium.devtools.idealized.log.Log {

@Override
public Command<Void> enable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.devtools.v103;
package org.openqa.selenium.devtools.v106;

import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams;

import org.openqa.selenium.UsernameAndPassword;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.DevToolsException;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.idealized.Network;
import org.openqa.selenium.devtools.v103.fetch.Fetch;
import org.openqa.selenium.devtools.v103.fetch.model.AuthChallengeResponse;
import org.openqa.selenium.devtools.v103.fetch.model.AuthRequired;
import org.openqa.selenium.devtools.v103.fetch.model.HeaderEntry;
import org.openqa.selenium.devtools.v103.fetch.model.RequestPattern;
import org.openqa.selenium.devtools.v103.fetch.model.RequestPaused;
import org.openqa.selenium.devtools.v103.fetch.model.RequestStage;
import org.openqa.selenium.devtools.v103.network.model.Request;
import org.openqa.selenium.devtools.v106.fetch.Fetch;
import org.openqa.selenium.devtools.v106.fetch.model.AuthChallengeResponse;
import org.openqa.selenium.devtools.v106.fetch.model.AuthRequired;
import org.openqa.selenium.devtools.v106.fetch.model.HeaderEntry;
import org.openqa.selenium.devtools.v106.fetch.model.RequestPattern;
import org.openqa.selenium.devtools.v106.fetch.model.RequestPaused;
import org.openqa.selenium.devtools.v106.fetch.model.RequestStage;
import org.openqa.selenium.devtools.v106.network.model.Request;
import org.openqa.selenium.internal.Either;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;
Expand All @@ -51,28 +50,28 @@

import static java.net.HttpURLConnection.HTTP_OK;

public class V103Network extends Network<AuthRequired, RequestPaused> {
public class V106Network extends Network<AuthRequired, RequestPaused> {

private static final Logger LOG = Logger.getLogger(V103Network.class.getName());
private static final Logger LOG = Logger.getLogger(V106Network.class.getName());

public V103Network(DevTools devTools) {
public V106Network(DevTools devTools) {
super(devTools);
}

@Override
protected Command<Void> setUserAgentOverride(UserAgent userAgent) {
return org.openqa.selenium.devtools.v103.network.Network.setUserAgentOverride(
return org.openqa.selenium.devtools.v106.network.Network.setUserAgentOverride(
userAgent.userAgent(), userAgent.acceptLanguage(), userAgent.platform(), Optional.empty());
}

@Override
protected Command<Void> enableNetworkCaching() {
return org.openqa.selenium.devtools.v103.network.Network.setCacheDisabled(false);
return org.openqa.selenium.devtools.v106.network.Network.setCacheDisabled(false);
}

@Override
protected Command<Void> disableNetworkCaching() {
return org.openqa.selenium.devtools.v103.network.Network.setCacheDisabled(true);
return org.openqa.selenium.devtools.v106.network.Network.setCacheDisabled(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.devtools.v103;
package org.openqa.selenium.devtools.v106;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.ConverterFunctions;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.idealized.browser.model.BrowserContextID;
import org.openqa.selenium.devtools.idealized.target.model.SessionID;
import org.openqa.selenium.devtools.idealized.target.model.TargetID;
import org.openqa.selenium.devtools.v103.target.Target;
import org.openqa.selenium.devtools.v103.target.model.TargetInfo;
import org.openqa.selenium.devtools.v106.target.Target;
import org.openqa.selenium.devtools.v106.target.model.TargetFilter;
import org.openqa.selenium.devtools.v106.target.model.TargetInfo;
import org.openqa.selenium.json.JsonInput;
import org.openqa.selenium.json.TypeToken;

import java.util.List;
import java.util.Optional;
import java.util.function.Function;

public class V103Target implements org.openqa.selenium.devtools.idealized.target.Target {
public class V106Target implements org.openqa.selenium.devtools.idealized.target.Target {

@Override
public Command<Void> detachFromTarget(Optional<SessionID> sessionId,
Optional<TargetID> targetId) {
return Target.detachFromTarget(
sessionId.map(
id -> new org.openqa.selenium.devtools.v103.target.model.SessionID(id.toString())),
id -> new org.openqa.selenium.devtools.v106.target.model.SessionID(id.toString())),
targetId.map(
id -> new org.openqa.selenium.devtools.v103.target.model.TargetID(id.toString())));
id -> new org.openqa.selenium.devtools.v106.target.model.TargetID(id.toString())));
}

@Override
Expand All @@ -55,7 +55,7 @@ public Command<List<org.openqa.selenium.devtools.idealized.target.model.TargetIn
}.getType());

return new Command<>(
Target.getTargets().getMethod(),
Target.getTargets(Optional.empty()).getMethod(),
ImmutableMap.of(),
input -> {
List<TargetInfo> infos = mapper.apply(input);
Expand All @@ -75,35 +75,35 @@ public Command<List<org.openqa.selenium.devtools.idealized.target.model.TargetIn

@Override
public Command<SessionID> attachToTarget(TargetID targetId) {
Function<JsonInput, org.openqa.selenium.devtools.v103.target.model.SessionID> mapper =
Function<JsonInput, org.openqa.selenium.devtools.v106.target.model.SessionID> mapper =
ConverterFunctions.map("sessionId",
org.openqa.selenium.devtools.v103.target.model.SessionID.class);
org.openqa.selenium.devtools.v106.target.model.SessionID.class);

return new Command<>(
"Target.attachToTarget",
ImmutableMap.of(
"targetId",
new org.openqa.selenium.devtools.v103.target.model.TargetID(targetId.toString()),
new org.openqa.selenium.devtools.v106.target.model.TargetID(targetId.toString()),
"flatten", true),
input -> {
org.openqa.selenium.devtools.v103.target.model.SessionID id = mapper.apply(input);
org.openqa.selenium.devtools.v106.target.model.SessionID id = mapper.apply(input);
return new SessionID(id.toString());
});
}

@Override
public Command<Void> setAutoAttach() {
return Target.setAutoAttach(true, false, Optional.of(true));
return Target.setAutoAttach(true, false, Optional.of(true), Optional.empty());
}

@Override
public Event<TargetID> detached() {
return new Event<>(
"Target.detachedFromTarget",
input -> {
Function<JsonInput, org.openqa.selenium.devtools.v103.target.model.TargetID> converter =
Function<JsonInput, org.openqa.selenium.devtools.v106.target.model.TargetID> converter =
ConverterFunctions.map("targetId",
org.openqa.selenium.devtools.v103.target.model.TargetID.class);
org.openqa.selenium.devtools.v106.target.model.TargetID.class);
return new TargetID(converter.apply(input).toString());
}
);
Expand Down
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/devtools/versions.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CDP_VERSIONS = [
"v85", # Required by Firefox
"v103",
"v104",
"v105"
"v105",
"v106"
]

CDP_DEPS = ["//java/src/org/openqa/selenium/devtools/%s" % v for v in CDP_VERSIONS]

0 comments on commit 2a05eb1

Please sign in to comment.