From a171c3960117f652522755abbb9b0e321a615f49 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 24 Aug 2021 18:26:01 +0200 Subject: [PATCH] feat(roll): roll Playwright to 1.15.0-next-1629487941000 (#583) --- .../com/microsoft/playwright/BrowserType.java | 12 ++++++---- .../java/com/microsoft/playwright/Frame.java | 16 +++++++------- .../java/com/microsoft/playwright/Page.java | 12 +++++----- .../java/com/microsoft/playwright/Route.java | 4 ++-- .../playwright/impl/BrowserImpl.java | 1 - .../playwright/impl/BrowserTypeImpl.java | 4 +--- .../microsoft/playwright/impl/Connection.java | 22 +++++++++---------- .../playwright/impl/PlaywrightImpl.java | 2 +- scripts/CLI_VERSION | 2 +- 9 files changed, 38 insertions(+), 37 deletions(-) diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java index cd8b82ad..de852d70 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java @@ -144,7 +144,8 @@ public interface BrowserType { public Boolean devtools; /** * If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is - * deleted when browser is closed. + * deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in + * is closed. */ public Path downloadsPath; /** @@ -253,7 +254,8 @@ public interface BrowserType { } /** * If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is - * deleted when browser is closed. + * deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in + * is closed. */ public LaunchOptions setDownloadsPath(Path downloadsPath) { this.downloadsPath = downloadsPath; @@ -418,7 +420,8 @@ public interface BrowserType { public Boolean devtools; /** * If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is - * deleted when browser is closed. + * deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in + * is closed. */ public Path downloadsPath; /** @@ -657,7 +660,8 @@ public interface BrowserType { } /** * If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is - * deleted when browser is closed. + * deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in + * is closed. */ public LaunchPersistentContextOptions setDownloadsPath(Path downloadsPath) { this.downloadsPath = downloadsPath; diff --git a/playwright/src/main/java/com/microsoft/playwright/Frame.java b/playwright/src/main/java/com/microsoft/playwright/Frame.java index a7b78243..8b78e874 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Frame.java +++ b/playwright/src/main/java/com/microsoft/playwright/Frame.java @@ -2569,7 +2569,7 @@ public interface Frame { * Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the * last redirect. * - *

{@code frame.goto} will throw an error if: + *

The method will throw an error if: *

* - *

{@code frame.goto} will not throw an error when any valid HTTP status code is returned by the remote server, including 404 - * "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling {@link + *

The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not + * Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling {@link * Response#status Response.status()}. * - *

NOTE: {@code frame.goto} either throws an error or returns a main resource response. The only exceptions are navigation to + *

NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to * {@code about:blank} or navigation to the same URL with a different hash, which would succeed and return {@code null}. * *

NOTE: Headless mode doesn't support navigation to a PDF document. See the {@code frame.goto} will throw an error if: + *

The method will throw an error if: *

* - *

{@code frame.goto} will not throw an error when any valid HTTP status code is returned by the remote server, including 404 - * "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling {@link + *

The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not + * Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling {@link * Response#status Response.status()}. * - *

NOTE: {@code frame.goto} either throws an error or returns a main resource response. The only exceptions are navigation to + *

NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to * {@code about:blank} or navigation to the same URL with a different hash, which would succeed and return {@code null}. * *

NOTE: Headless mode doesn't support navigation to a PDF document. See the {@code page.goto} will throw an error if: + *

The method will throw an error if: *

* - *

{@code page.goto} will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not + *

The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not * Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling {@link * Response#status Response.status()}. * - *

NOTE: {@code page.goto} either throws an error or returns a main resource response. The only exceptions are navigation to + *

NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to * {@code about:blank} or navigation to the same URL with a different hash, which would succeed and return {@code null}. * *

NOTE: Headless mode doesn't support navigation to a PDF document. See the {@code page.goto} will throw an error if: + *

The method will throw an error if: *

* - *

{@code page.goto} will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not + *

The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not * Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling {@link * Response#status Response.status()}. * - *

NOTE: {@code page.goto} either throws an error or returns a main resource response. The only exceptions are navigation to + *

NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to * {@code about:blank} or navigation to the same URL with a different hash, which would succeed and return {@code null}. * *

NOTE: Headless mode doesn't support navigation to a PDF document. See the An example of serving static file: *

{@code
    * page.route("**\/xhr_endpoint", route -> route.fulfill(
-   *   new Route.FulfillOptions().setPath(Paths.get("mock_data.json")));
+   *   new Route.FulfillOptions().setPath(Paths.get("mock_data.json"))));
    * }
*/ default void fulfill() { @@ -246,7 +246,7 @@ public interface Route { *

An example of serving static file: *

{@code
    * page.route("**\/xhr_endpoint", route -> route.fulfill(
-   *   new Route.FulfillOptions().setPath(Paths.get("mock_data.json")));
+   *   new Route.FulfillOptions().setPath(Paths.get("mock_data.json"))));
    * }
*/ void fulfill(FulfillOptions options); diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java index 2cd546b8..5d9c5b72 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java @@ -165,7 +165,6 @@ class BrowserImpl extends ChannelOwner implements Browser { params.addProperty("noDefaultViewport", true); } } - params.addProperty("sdkLanguage", "java"); JsonElement result = sendMessage("newContext", params); BrowserContextImpl context = connection.getExistingObject(result.getAsJsonObject().getAsJsonObject("context").get("guid").getAsString()); if (options.recordVideoDir != null) { diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserTypeImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserTypeImpl.java index 9a78a4ad..0f0e8f43 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserTypeImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserTypeImpl.java @@ -75,7 +75,7 @@ class BrowserTypeImpl extends ChannelOwner implements BrowserType { } WebSocketTransport transport = new WebSocketTransport(new URI(wsEndpoint), headers, timeout, slowMo); Connection connection = new Connection(transport); - PlaywrightImpl playwright = (PlaywrightImpl) connection.waitForObjectWithKnownName("Playwright"); + PlaywrightImpl playwright = connection.initializePlaywright(); if (!playwright.initializer.has("preLaunchedBrowser")) { try { connection.close(); @@ -119,7 +119,6 @@ class BrowserTypeImpl extends ChannelOwner implements BrowserType { } JsonObject params = gson().toJsonTree(options).getAsJsonObject(); - params.addProperty("sdkLanguage", "java"); params.addProperty("endpointURL", endpointURL); JsonObject json = sendMessage("connectOverCDP", params).getAsJsonObject(); @@ -183,7 +182,6 @@ class BrowserTypeImpl extends ChannelOwner implements BrowserType { params.addProperty("noDefaultViewport", true); } } - params.addProperty("sdkLanguage", "java"); JsonObject json = sendMessage("launchPersistentContext", params).getAsJsonObject(); BrowserContextImpl context = connection.getExistingObject(json.getAsJsonObject("context").get("guid").getAsString()); if (options.recordVideoDir != null) { diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/Connection.java b/playwright/src/main/java/com/microsoft/playwright/impl/Connection.java index fae7244f..e29ce741 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/Connection.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/Connection.java @@ -19,16 +19,12 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.microsoft.playwright.Playwright; import com.microsoft.playwright.PlaywrightException; import com.microsoft.playwright.TimeoutError; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -77,7 +73,14 @@ public class Connection { class Root extends ChannelOwner { Root(Connection connection) { - super(connection, "", ""); + super(connection, "Root", ""); + } + + Playwright initialize() { + JsonObject params = new JsonObject(); + params.addProperty("sdkLanguage", "java"); + JsonElement result = sendMessage("initialize", params.getAsJsonObject()); + return this.connection.getExistingObject(result.getAsJsonObject().getAsJsonObject("playwright").get("guid").getAsString()); } } @@ -177,11 +180,8 @@ public class Connection { return result; } - public ChannelOwner waitForObjectWithKnownName(String guid) { - while (!objects.containsKey(guid)) { - processOneMessage(); - } - return objects.get(guid); + public PlaywrightImpl initializePlaywright() { + return (PlaywrightImpl) this.root.initialize(); } public T getExistingObject(String guid) { diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/PlaywrightImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/PlaywrightImpl.java index ac5e5d71..d975fedb 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/PlaywrightImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/PlaywrightImpl.java @@ -42,7 +42,7 @@ public class PlaywrightImpl extends ChannelOwner implements Playwright { pb.environment().putAll(env); Process p = pb.start(); Connection connection = new Connection(new PipeTransport(p.getInputStream(), p.getOutputStream())); - PlaywrightImpl result = (PlaywrightImpl) connection.waitForObjectWithKnownName("Playwright"); + PlaywrightImpl result = connection.initializePlaywright(); result.driverProcess = p; result.initSharedSelectors(null); return result; diff --git a/scripts/CLI_VERSION b/scripts/CLI_VERSION index eb34cf7c..d35b6d2d 100644 --- a/scripts/CLI_VERSION +++ b/scripts/CLI_VERSION @@ -1 +1 @@ -1.15.0-next-1629322356000 +1.15.0-next-1629487941000