From 31027c88356ba2b6a9efd7f50702829fa7dfcf5f Mon Sep 17 00:00:00 2001 From: Simon Mavi Stewart Date: Sat, 25 Sep 2021 14:47:15 +0100 Subject: [PATCH] [cdp] Add support for v94 and remove v93 --- Rakefile | 2 +- java/CHANGELOG | 2 +- .../devtools/{v92 => v94}/BUILD.bazel | 2 +- .../V92CdpInfo.java => v94/V94CdpInfo.java} | 8 ++--- .../V92Domains.java => v94/V94Domains.java} | 26 +++++++------- .../V92Events.java => v94/V94Events.java} | 18 +++++----- .../V94Javascript.java} | 14 ++++---- .../{v92/V92Log.java => v94/V94Log.java} | 10 +++--- .../V92Network.java => v94/V94Network.java} | 34 ++++++++++--------- .../V92Target.java => v94/V94Target.java} | 20 +++++------ .../org/openqa/selenium/devtools/versions.bzl | 2 +- .../devtools/NetworkInterceptorTest.java | 3 ++ 12 files changed, 73 insertions(+), 68 deletions(-) rename java/src/org/openqa/selenium/devtools/{v92 => v94}/BUILD.bazel (98%) rename java/src/org/openqa/selenium/devtools/{v92/V92CdpInfo.java => v94/V94CdpInfo.java} (86%) rename java/src/org/openqa/selenium/devtools/{v92/V92Domains.java => v94/V94Domains.java} (77%) rename java/src/org/openqa/selenium/devtools/{v92/V92Events.java => v94/V94Events.java} (86%) rename java/src/org/openqa/selenium/devtools/{v92/V92Javascript.java => v94/V94Javascript.java} (85%) rename java/src/org/openqa/selenium/devtools/{v92/V92Log.java => v94/V94Log.java} (89%) rename java/src/org/openqa/selenium/devtools/{v92/V92Network.java => v94/V94Network.java} (87%) rename java/src/org/openqa/selenium/devtools/{v92/V92Target.java => v94/V94Target.java} (84%) diff --git a/Rakefile b/Rakefile index 4791ae7dbcae5..f3aff6ac6c604 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/java/CHANGELOG b/java/CHANGELOG index 31f5af3acf60e..b6a3c8991d2a6 100644 --- a/java/CHANGELOG +++ b/java/CHANGELOG @@ -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. diff --git a/java/src/org/openqa/selenium/devtools/v92/BUILD.bazel b/java/src/org/openqa/selenium/devtools/v94/BUILD.bazel similarity index 98% rename from java/src/org/openqa/selenium/devtools/v92/BUILD.bazel rename to java/src/org/openqa/selenium/devtools/v94/BUILD.bazel index a93bdc7c8137f..37ebad445c84e 100644 --- a/java/src/org/openqa/selenium/devtools/v92/BUILD.bazel +++ b/java/src/org/openqa/selenium/devtools/v94/BUILD.bazel @@ -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, diff --git a/java/src/org/openqa/selenium/devtools/v92/V92CdpInfo.java b/java/src/org/openqa/selenium/devtools/v94/V94CdpInfo.java similarity index 86% rename from java/src/org/openqa/selenium/devtools/v92/V92CdpInfo.java rename to java/src/org/openqa/selenium/devtools/v94/V94CdpInfo.java index 4066d9e9908b5..d694dbf90d21d 100644 --- a/java/src/org/openqa/selenium/devtools/v92/V92CdpInfo.java +++ b/java/src/org/openqa/selenium/devtools/v94/V94CdpInfo.java @@ -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); } } diff --git a/java/src/org/openqa/selenium/devtools/v92/V92Domains.java b/java/src/org/openqa/selenium/devtools/v94/V94Domains.java similarity index 77% rename from java/src/org/openqa/selenium/devtools/v92/V92Domains.java rename to java/src/org/openqa/selenium/devtools/v94/V94Domains.java index 755b9ceed893f..8d0c3fbe18555 100644 --- a/java/src/org/openqa/selenium/devtools/v92/V92Domains.java +++ b/java/src/org/openqa/selenium/devtools/v94/V94Domains.java @@ -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; @@ -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 diff --git a/java/src/org/openqa/selenium/devtools/v92/V92Events.java b/java/src/org/openqa/selenium/devtools/v94/V94Events.java similarity index 86% rename from java/src/org/openqa/selenium/devtools/v92/V92Events.java rename to java/src/org/openqa/selenium/devtools/v94/V94Events.java index 6e1e0bc52ab84..2253aaf700316 100644 --- a/java/src/org/openqa/selenium/devtools/v92/V92Events.java +++ b/java/src/org/openqa/selenium/devtools/v94/V94Events.java @@ -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; @@ -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 { +public class V94Events extends Events { - public V92Events(DevTools devtools) { + public V94Events(DevTools devtools) { super(devtools); } @@ -82,7 +82,7 @@ protected ConsoleEvent toConsoleEvent(ConsoleAPICalled event) { protected JavascriptException toJsException(ExceptionThrown event) { ExceptionDetails details = event.getExceptionDetails(); Optional maybeTrace = details.getStackTrace(); - Optional + Optional maybeException = details.getException(); String message = maybeException diff --git a/java/src/org/openqa/selenium/devtools/v92/V92Javascript.java b/java/src/org/openqa/selenium/devtools/v94/V94Javascript.java similarity index 85% rename from java/src/org/openqa/selenium/devtools/v92/V92Javascript.java rename to java/src/org/openqa/selenium/devtools/v94/V94Javascript.java index fcef30aa838d4..6394001a4d552 100644 --- a/java/src/org/openqa/selenium/devtools/v92/V92Javascript.java +++ b/java/src/org/openqa/selenium/devtools/v94/V94Javascript.java @@ -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 { +public class V94Javascript extends Javascript { - public V92Javascript(DevTools devtools) { + public V94Javascript(DevTools devtools) { super(devtools); } diff --git a/java/src/org/openqa/selenium/devtools/v92/V92Log.java b/java/src/org/openqa/selenium/devtools/v94/V94Log.java similarity index 89% rename from java/src/org/openqa/selenium/devtools/v92/V92Log.java rename to java/src/org/openqa/selenium/devtools/v94/V94Log.java index bc6c040ea60e1..1fa12fa5e6cb4 100644 --- a/java/src/org/openqa/selenium/devtools/v92/V92Log.java +++ b/java/src/org/openqa/selenium/devtools/v94/V94Log.java @@ -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 enable() { return Log.enable(); diff --git a/java/src/org/openqa/selenium/devtools/v92/V92Network.java b/java/src/org/openqa/selenium/devtools/v94/V94Network.java similarity index 87% rename from java/src/org/openqa/selenium/devtools/v92/V92Network.java rename to java/src/org/openqa/selenium/devtools/v94/V94Network.java index 8a5d2f7c9635c..5bab6b1bd1373 100644 --- a/java/src/org/openqa/selenium/devtools/v92/V92Network.java +++ b/java/src/org/openqa/selenium/devtools/v94/V94Network.java @@ -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; @@ -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; @@ -50,28 +50,28 @@ import static java.net.HttpURLConnection.HTTP_OK; -public class V92Network extends Network { +public class V94Network extends Network { - 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 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 enableNetworkCaching() { - return org.openqa.selenium.devtools.v92.network.Network.setCacheDisabled(false); + return org.openqa.selenium.devtools.v94.network.Network.setCacheDisabled(false); } @Override protected Command disableNetworkCaching() { - return org.openqa.selenium.devtools.v92.network.Network.setCacheDisabled(true); + return org.openqa.selenium.devtools.v94.network.Network.setCacheDisabled(true); } @Override @@ -177,6 +177,7 @@ protected Command continueWithoutModification(RequestPaused pausedRequest) Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); } @@ -197,7 +198,8 @@ protected Command 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 diff --git a/java/src/org/openqa/selenium/devtools/v92/V92Target.java b/java/src/org/openqa/selenium/devtools/v94/V94Target.java similarity index 84% rename from java/src/org/openqa/selenium/devtools/v92/V92Target.java rename to java/src/org/openqa/selenium/devtools/v94/V94Target.java index 26141884f0511..e594388834e84 100644 --- a/java/src/org/openqa/selenium/devtools/v92/V92Target.java +++ b/java/src/org/openqa/selenium/devtools/v94/V94Target.java @@ -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; @@ -24,8 +24,8 @@ 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; @@ -33,12 +33,12 @@ 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 detachFromTarget(Optional sessionId, Optional 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 @@ -68,16 +68,16 @@ public Command attachToTarget(TargetID targetId) { - Function mapper = - ConverterFunctions.map("sessionId", org.openqa.selenium.devtools.v92.target.model.SessionID.class); + Function 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()); }); } diff --git a/java/src/org/openqa/selenium/devtools/versions.bzl b/java/src/org/openqa/selenium/devtools/versions.bzl index a367fb1ce5e46..96214a8205db7 100644 --- a/java/src/org/openqa/selenium/devtools/versions.bzl +++ b/java/src/org/openqa/selenium/devtools/versions.bzl @@ -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] diff --git a/java/test/org/openqa/selenium/devtools/NetworkInterceptorTest.java b/java/test/org/openqa/selenium/devtools/NetworkInterceptorTest.java index fa9a1df55340f..8f4542fd5571c 100644 --- a/java/test/org/openqa/selenium/devtools/NetworkInterceptorTest.java +++ b/java/test/org/openqa/selenium/devtools/NetworkInterceptorTest.java @@ -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; @@ -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(); }