From 5bc9845f26980ba50dd458a19e113b769b9495da Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 11 Nov 2026 11:28:36 -0800 Subject: [PATCH 1/2] chore(driver): roll to 1.65.0 - CDPSession.send: new timeout option - declare supportsLoneSurrogates to the driver - JSON-stringify string data when the content-type has parameters - recognize .zip HAR paths regardless of case - reset the trace stack counter when a context or a request context closes - remove the @Fixme marks of the tests that pass with the new driver --- README.md | 4 +- .../microsoft/playwright/BrowserContext.java | 24 ++++++------ .../com/microsoft/playwright/BrowserType.java | 30 ++++++++++----- .../com/microsoft/playwright/CDPSession.java | 26 ++++++++++++- .../java/com/microsoft/playwright/Clock.java | 16 ++++---- .../com/microsoft/playwright/Locator.java | 8 +++- .../impl/APIRequestContextImpl.java | 3 +- .../playwright/impl/BrowserContextImpl.java | 4 +- .../playwright/impl/CDPSessionImpl.java | 6 ++- .../microsoft/playwright/impl/Connection.java | 1 + .../playwright/impl/TracingImpl.java | 18 ++++++--- .../TestBrowserContextCDPSession.java | 17 +++++++++ .../TestBrowserContextStorageState.java | 2 +- .../microsoft/playwright/TestGlobalFetch.java | 2 +- .../microsoft/playwright/TestPageFill.java | 38 ------------------- .../playwright/TestPageRequestContinue.java | 4 +- .../playwright/TestTracingOverConnect.java | 13 +++++++ .../library/TestBrowsercontextCookies.java | 1 - .../TestBrowsercontextCookiesThirdParty.java | 3 +- .../tests/library/TestBrowsercontextCsp.java | 1 - .../tests/library/TestBrowsercontextHar.java | 1 - .../library/TestBrowsercontextLocale.java | 1 - .../TestBrowsercontextStorageState.java | 1 - .../tests/library/TestEmulationCoop.java | 3 -- .../tests/library/TestGlobalFetch.java | 4 +- .../tests/library/TestGlobalFetchCookie.java | 3 -- .../playwright/tests/library/TestHar.java | 3 -- .../tests/library/TestPageClock.java | 2 - .../playwright/tests/library/TestProxy.java | 2 - .../playwright/tests/library/TestTracing.java | 1 - .../playwright/tests/library/TestWebmcp.java | 3 +- .../tests/page/TestPageAriaSnapshot.java | 3 -- .../tests/page/TestPageAriaSnapshotAi.java | 1 - .../playwright/tests/page/TestPageClick.java | 1 - .../playwright/tests/page/TestPageDrag.java | 1 - .../tests/page/TestPageEvaluate.java | 1 - .../tests/page/TestPageEventPageerror.java | 1 - .../tests/page/TestPageEventRequest.java | 1 - .../tests/page/TestPageFilechooser.java | 2 - .../playwright/tests/page/TestPageFill.java | 5 --- .../playwright/tests/page/TestPageFocus.java | 2 - .../playwright/tests/page/TestPageMouse.java | 4 +- .../tests/page/TestPageSetInputFiles.java | 1 - playwright/src/test/upstream_not_ported.txt | 2 +- scripts/DRIVER_VERSION | 2 +- 45 files changed, 138 insertions(+), 134 deletions(-) diff --git a/README.md b/README.md index 8f6b68a57..aa9ab07c3 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 156.0.8078.4 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Chromium 158.0.8127.18 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 27.2 | ✅ | ✅ | ✅ | -| Firefox 157.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Firefox 159.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | ## Documentation diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java index 196b95db7..a8920e118 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java @@ -1388,12 +1388,12 @@ default void routeFromHAR(Path har) { * and examples. *
{@code
    * context.routeWebSocket("/ws", ws -> {
-   *   ws.routeSend(message -> {
-   *     if ("to-be-blocked".equals(message))
+   *   WebSocketRoute server = ws.connectToServer();
+   *   ws.onMessage(frame -> {
+   *     if ("to-be-blocked".equals(frame.text()))
    *       return;
-   *     ws.send(message);
+   *     server.send(frame.text());
    *   });
-   *   ws.connect();
    * });
    * }
* @@ -1415,12 +1415,12 @@ default void routeFromHAR(Path har) { * and examples. *
{@code
    * context.routeWebSocket("/ws", ws -> {
-   *   ws.routeSend(message -> {
-   *     if ("to-be-blocked".equals(message))
+   *   WebSocketRoute server = ws.connectToServer();
+   *   ws.onMessage(frame -> {
+   *     if ("to-be-blocked".equals(frame.text()))
    *       return;
-   *     ws.send(message);
+   *     server.send(frame.text());
    *   });
-   *   ws.connect();
    * });
    * }
* @@ -1442,12 +1442,12 @@ default void routeFromHAR(Path har) { * and examples. *
{@code
    * context.routeWebSocket("/ws", ws -> {
-   *   ws.routeSend(message -> {
-   *     if ("to-be-blocked".equals(message))
+   *   WebSocketRoute server = ws.connectToServer();
+   *   ws.onMessage(frame -> {
+   *     if ("to-be-blocked".equals(frame.text()))
    *       return;
-   *     ws.send(message);
+   *     server.send(frame.text());
    *   });
-   *   ws.connect();
    * });
    * }
* diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java index 2e0f97804..62b38ac26 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java @@ -140,11 +140,11 @@ class ConnectOverCDPOptions { public @Nullable Boolean isLocal; /** * When true, Playwright will not apply its default overrides to the existing default browser context. Specifically, {@code - * acceptDownloads} is left at the browser's setting, focus emulation is not enabled, and media emulation options (such as - * {@code colorScheme}, {@code reducedMotion}, {@code forcedColors}, and {@code contrast}) are not applied. Useful when - * attaching to a user's daily-driver browser where these overrides would interfere with existing browser state. New - * contexts created via {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} are not affected. Defaults - * to {@code false}. + * acceptDownloads} and font families are left at the browser's settings, focus emulation is not enabled, and media + * emulation options (such as {@code colorScheme}, {@code reducedMotion}, {@code forcedColors}, and {@code contrast}) are + * not applied. Useful when attaching to a user's daily-driver browser where these overrides would interfere with existing + * browser state. New contexts created via {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} are not + * affected. Defaults to {@code false}. */ public @Nullable Boolean noDefaults; /** @@ -182,11 +182,11 @@ public ConnectOverCDPOptions setIsLocal(boolean isLocal) { } /** * When true, Playwright will not apply its default overrides to the existing default browser context. Specifically, {@code - * acceptDownloads} is left at the browser's setting, focus emulation is not enabled, and media emulation options (such as - * {@code colorScheme}, {@code reducedMotion}, {@code forcedColors}, and {@code contrast}) are not applied. Useful when - * attaching to a user's daily-driver browser where these overrides would interfere with existing browser state. New - * contexts created via {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} are not affected. Defaults - * to {@code false}. + * acceptDownloads} and font families are left at the browser's settings, focus emulation is not enabled, and media + * emulation options (such as {@code colorScheme}, {@code reducedMotion}, {@code forcedColors}, and {@code contrast}) are + * not applied. Useful when attaching to a user's daily-driver browser where these overrides would interfere with existing + * browser state. New contexts created via {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} are not + * affected. Defaults to {@code false}. */ public ConnectOverCDPOptions setNoDefaults(boolean noDefaults) { this.noDefaults = noDefaults; @@ -1360,6 +1360,11 @@ default Browser connect(String endpoint) { * * @param endpointURL A CDP websocket endpoint or http url to connect to. For example {@code http://localhost:9222/} or {@code * ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4}. + * + *

Alternatively, a browser channel name such as {@code chrome} or {@code msedge} to connect to a browser with remote + * debugging enabled in its default user data directory. On Linux, Playwright uses {@code CHROME_USER_DATA_DIR} when set. + * Otherwise, it uses {@code CHROME_CONFIG_HOME}, then {@code XDG_CONFIG_HOME}, then {@code ~/.config} to locate that + * directory. * @since v1.9 */ default Browser connectOverCDP(String endpointURL) { @@ -1389,6 +1394,11 @@ default Browser connectOverCDP(String endpointURL) { * * @param endpointURL A CDP websocket endpoint or http url to connect to. For example {@code http://localhost:9222/} or {@code * ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4}. + * + *

Alternatively, a browser channel name such as {@code chrome} or {@code msedge} to connect to a browser with remote + * debugging enabled in its default user data directory. On Linux, Playwright uses {@code CHROME_USER_DATA_DIR} when set. + * Otherwise, it uses {@code CHROME_CONFIG_HOME}, then {@code XDG_CONFIG_HOME}, then {@code ~/.config} to locate that + * directory. * @since v1.9 */ Browser connectOverCDP(String endpointURL, @Nullable ConnectOverCDPOptions options); diff --git a/playwright/src/main/java/com/microsoft/playwright/CDPSession.java b/playwright/src/main/java/com/microsoft/playwright/CDPSession.java index 7760ca63d..0b722c394 100644 --- a/playwright/src/main/java/com/microsoft/playwright/CDPSession.java +++ b/playwright/src/main/java/com/microsoft/playwright/CDPSession.java @@ -59,6 +59,20 @@ public interface CDPSession { */ void offClose(Consumer handler); + class SendOptions { + /** + * Maximum time in milliseconds to wait for the response. Defaults to {@code 0} - no timeout. + */ + public @Nullable Double timeout; + + /** + * Maximum time in milliseconds to wait for the response. Defaults to {@code 0} - no timeout. + */ + public SendOptions setTimeout(double timeout) { + this.timeout = timeout; + return this; + } + } /** * Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to * send messages. @@ -66,6 +80,16 @@ public interface CDPSession { * @since v1.8 */ void detach(); + /** + * + * + * @param method Protocol method name. + * @param args Optional method parameters. + * @since v1.8 + */ + default JsonObject send(String method, @Nullable JsonObject args) { + return send(method, args, null); + } /** * * @@ -82,7 +106,7 @@ default JsonObject send(String method) { * @param args Optional method parameters. * @since v1.8 */ - JsonObject send(String method, @Nullable JsonObject args); + JsonObject send(String method, @Nullable JsonObject args, @Nullable SendOptions options); /** * Register an event handler for events with the specified event name. The given handler will be called for every event * with the given name. diff --git a/playwright/src/main/java/com/microsoft/playwright/Clock.java b/playwright/src/main/java/com/microsoft/playwright/Clock.java index 1992d4c61..a37b27b51 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Clock.java +++ b/playwright/src/main/java/com/microsoft/playwright/Clock.java @@ -65,8 +65,8 @@ public InstallOptions setTime(Date time) { * page.clock().fastForward("30:00"); * } * - * @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08" - * for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds. + * @param ticks Time may be a finite number of milliseconds to advance the clock by or a human-readable string. Valid string formats are + * "08" for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds. * @since v1.45 */ void fastForward(long ticks); @@ -80,8 +80,8 @@ public InstallOptions setTime(Date time) { * page.clock().fastForward("30:00"); * } * - * @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08" - * for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds. + * @param ticks Time may be a finite number of milliseconds to advance the clock by or a human-readable string. Valid string formats are + * "08" for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds. * @since v1.45 */ void fastForward(String ticks); @@ -142,8 +142,8 @@ default void install() { * page.clock().runFor("30:00"); * } * - * @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08" - * for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds. + * @param ticks Time may be a finite number of milliseconds to advance the clock by or a human-readable string. Valid string formats are + * "08" for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds. * @since v1.45 */ void runFor(long ticks); @@ -156,8 +156,8 @@ default void install() { * page.clock().runFor("30:00"); * } * - * @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08" - * for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds. + * @param ticks Time may be a finite number of milliseconds to advance the clock by or a human-readable string. Valid string formats are + * "08" for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds. * @since v1.45 */ void runFor(String ticks); diff --git a/playwright/src/main/java/com/microsoft/playwright/Locator.java b/playwright/src/main/java/com/microsoft/playwright/Locator.java index ff57fa4e4..6a3f129fc 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Locator.java +++ b/playwright/src/main/java/com/microsoft/playwright/Locator.java @@ -2586,7 +2586,9 @@ public WaitForFunctionOptions setTimeout(double timeout) { *

An AI-optimized snapshot, controlled by {@code mode}, is different from a default snapshot: *

    *
  1. Includes element references {@code [ref=e2]}. 2. Does not wait for an element matching the locator, and throws when no - * elements match. 3. Includes snapshots of {@code