Skip to content

Commit

Permalink
[cdp] Add support for v94 and remove v93
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Sep 25, 2021
1 parent d88bb08 commit 31027c8
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ 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/v92:v92.publish
//java/src/org/openqa/selenium/devtools/v93:v93.publish
//java/src/org/openqa/selenium/devtools/v94:v94.publish
//java/src/org/openqa/selenium/devtools:devtools.publish
//java/src/org/openqa/selenium/edge:edge.publish
//java/src/org/openqa/selenium/firefox/xpi:xpi.publish
Expand Down
2 changes: 1 addition & 1 deletion java/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
v4.0.0-rc-2
===========

* Supported CDP versions: 85, 92, 93
* Supported CDP versions: 85, 93, 94
* Moved NetworkInterceptor to org.opeqa.selenium.devtools
* NetworkInterceptor now takes a Filter to allow responses to be
captured and rewritten.
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 = "v92"
cdp_version = "v94"

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

package org.openqa.selenium.devtools.v92;
package org.openqa.selenium.devtools.v94;

import com.google.auto.service.AutoService;
import org.openqa.selenium.devtools.CdpInfo;

@AutoService(CdpInfo.class)
public class V92CdpInfo extends CdpInfo {
public class V94CdpInfo extends CdpInfo {

public V92CdpInfo() {
super(92, V92Domains::new);
public V94CdpInfo() {
super(94, V94Domains::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.v92;
package org.openqa.selenium.devtools.v94;

import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.idealized.Domains;
Expand All @@ -26,21 +26,21 @@
import org.openqa.selenium.devtools.idealized.target.Target;
import org.openqa.selenium.internal.Require;

public class V92Domains implements Domains {
public class V94Domains implements Domains {

private final V92Javascript js;
private final V92Events events;
private final V92Log log;
private final V92Network network;
private final V92Target target;
private final V94Javascript js;
private final V94Events events;
private final V94Log log;
private final V94Network network;
private final V94Target target;

public V92Domains(DevTools devtools) {
public V94Domains(DevTools devtools) {
Require.nonNull("DevTools", devtools);
events = new V92Events(devtools);
js = new V92Javascript(devtools);
log = new V92Log();
network = new V92Network(devtools);
target = new V92Target();
events = new V94Events(devtools);
js = new V94Javascript(devtools);
log = new V94Log();
network = new V94Network(devtools);
target = new V94Target();
}

@Override
Expand Down
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.v92;
package org.openqa.selenium.devtools.v94;

import com.google.common.collect.ImmutableList;
import org.openqa.selenium.JavascriptException;
Expand All @@ -25,20 +25,20 @@
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.v92.runtime.Runtime;
import org.openqa.selenium.devtools.v92.runtime.model.ConsoleAPICalled;
import org.openqa.selenium.devtools.v92.runtime.model.ExceptionDetails;
import org.openqa.selenium.devtools.v92.runtime.model.ExceptionThrown;
import org.openqa.selenium.devtools.v92.runtime.model.StackTrace;
import org.openqa.selenium.devtools.v94.runtime.Runtime;
import org.openqa.selenium.devtools.v94.runtime.model.ConsoleAPICalled;
import org.openqa.selenium.devtools.v94.runtime.model.ExceptionDetails;
import org.openqa.selenium.devtools.v94.runtime.model.ExceptionThrown;
import org.openqa.selenium.devtools.v94.runtime.model.StackTrace;

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

public class V92Events extends Events<ConsoleAPICalled, ExceptionThrown> {
public class V94Events extends Events<ConsoleAPICalled, ExceptionThrown> {

public V92Events(DevTools devtools) {
public V94Events(DevTools devtools) {
super(devtools);
}

Expand Down Expand Up @@ -82,7 +82,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.v92.runtime.model.RemoteObject>
Optional<org.openqa.selenium.devtools.v94.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.v92;
package org.openqa.selenium.devtools.v94;

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.v92.page.Page;
import org.openqa.selenium.devtools.v92.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v92.runtime.Runtime;
import org.openqa.selenium.devtools.v92.runtime.model.BindingCalled;
import org.openqa.selenium.devtools.v94.page.Page;
import org.openqa.selenium.devtools.v94.page.model.ScriptIdentifier;
import org.openqa.selenium.devtools.v94.runtime.Runtime;
import org.openqa.selenium.devtools.v94.runtime.model.BindingCalled;

import java.util.Optional;

public class V92Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
public class V94Javascript extends Javascript<ScriptIdentifier, BindingCalled> {

public V92Javascript(DevTools devtools) {
public V94Javascript(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.v92;
package org.openqa.selenium.devtools.v94;

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

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

public class V92Log implements org.openqa.selenium.devtools.idealized.log.Log {
public class V94Log implements org.openqa.selenium.devtools.idealized.log.Log {
@Override
public Command<Void> enable() {
return Log.enable();
Expand Down
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.v92;
package org.openqa.selenium.devtools.v94;

import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams;
Expand All @@ -25,14 +25,14 @@
import org.openqa.selenium.devtools.DevToolsException;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.idealized.Network;
import org.openqa.selenium.devtools.v92.fetch.Fetch;
import org.openqa.selenium.devtools.v92.fetch.model.AuthChallengeResponse;
import org.openqa.selenium.devtools.v92.fetch.model.AuthRequired;
import org.openqa.selenium.devtools.v92.fetch.model.HeaderEntry;
import org.openqa.selenium.devtools.v92.fetch.model.RequestPattern;
import org.openqa.selenium.devtools.v92.fetch.model.RequestPaused;
import org.openqa.selenium.devtools.v92.fetch.model.RequestStage;
import org.openqa.selenium.devtools.v92.network.model.Request;
import org.openqa.selenium.devtools.v94.fetch.Fetch;
import org.openqa.selenium.devtools.v94.fetch.model.AuthChallengeResponse;
import org.openqa.selenium.devtools.v94.fetch.model.AuthRequired;
import org.openqa.selenium.devtools.v94.fetch.model.HeaderEntry;
import org.openqa.selenium.devtools.v94.fetch.model.RequestPattern;
import org.openqa.selenium.devtools.v94.fetch.model.RequestPaused;
import org.openqa.selenium.devtools.v94.fetch.model.RequestStage;
import org.openqa.selenium.devtools.v94.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 @@ -50,28 +50,28 @@

import static java.net.HttpURLConnection.HTTP_OK;

public class V92Network extends Network<AuthRequired, RequestPaused> {
public class V94Network extends Network<AuthRequired, RequestPaused> {

private static final Logger LOG = Logger.getLogger(V92Network.class.getName());
private static final Logger LOG = Logger.getLogger(V94Network.class.getName());

public V92Network(DevTools devTools) {
public V94Network(DevTools devTools) {
super(devTools);
}

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

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

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

@Override
Expand Down Expand Up @@ -177,6 +177,7 @@ protected Command<Void> continueWithoutModification(RequestPaused pausedRequest)
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty());
}

Expand All @@ -197,7 +198,8 @@ protected Command<Void> continueRequest(RequestPaused pausedReq, HttpRequest req
Optional.empty(),
Optional.of(req.getMethod().toString()),
Optional.of(Base64.getEncoder().encodeToString(bos.toByteArray())),
Optional.of(headers));
Optional.of(headers),
Optional.empty());
}

@Override
Expand Down
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.v92;
package org.openqa.selenium.devtools.v94;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand All @@ -24,21 +24,21 @@
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.v92.target.Target;
import org.openqa.selenium.devtools.v92.target.model.TargetInfo;
import org.openqa.selenium.devtools.v94.target.Target;
import org.openqa.selenium.devtools.v94.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 V92Target implements org.openqa.selenium.devtools.idealized.target.Target {
public class V94Target 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.v92.target.model.SessionID(id.toString())),
targetId.map(id -> new org.openqa.selenium.devtools.v92.target.model.TargetID(id.toString())));
sessionId.map(id -> new org.openqa.selenium.devtools.v94.target.model.SessionID(id.toString())),
targetId.map(id -> new org.openqa.selenium.devtools.v94.target.model.TargetID(id.toString())));
}

@Override
Expand Down Expand Up @@ -68,16 +68,16 @@ public Command<List<org.openqa.selenium.devtools.idealized.target.model.TargetIn

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

return new Command<>(
"Target.attachToTarget",
ImmutableMap.of(
"targetId", new org.openqa.selenium.devtools.v92.target.model.TargetID(targetId.toString()),
"targetId", new org.openqa.selenium.devtools.v94.target.model.TargetID(targetId.toString()),
"flatten", true),
input -> {
org.openqa.selenium.devtools.v92.target.model.SessionID id = mapper.apply(input);
org.openqa.selenium.devtools.v94.target.model.SessionID id = mapper.apply(input);
return new SessionID(id.toString());
});
}
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/devtools/versions.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CDP_VERSIONS = [
"v85", # Required by Firefox
"v92",
"v93",
"v94",
]

CDP_DEPS = ["//java/src/org/openqa/selenium/devtools/%s" % v for v in CDP_VERSIONS]
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openqa.selenium.remote.http.Filter;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.http.Route;
import org.openqa.selenium.testing.drivers.Browser;
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -53,6 +54,8 @@ public class NetworkInterceptorTest {

@BeforeClass
public static void shouldTestBeRunAtAll() {
// Until Firefox can initialise the Fetch domain, we can remove this check
assumeThat(Browser.detect()).isNotEqualTo(Browser.FIREFOX);
assumeThat(Boolean.getBoolean("selenium.skiptest")).isFalse();
}

Expand Down

0 comments on commit 31027c8

Please sign in to comment.