@@ -927,7 +927,7 @@ default void grantPermissions(List<String> permissions) {
927927 *
928928 * <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
929929 * Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
930- * Service Workers when using request interception by setting {@code Browser.newContext. serviceWorkers} to {@code "block"}.
930+ * Service Workers when using request interception by setting {@code serviceWorkers} to {@code "block"}.
931931 *
932932 * <p> <strong>Usage</strong>
933933 *
@@ -983,7 +983,7 @@ default void route(String url, Consumer<Route> handler) {
983983 *
984984 * <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
985985 * Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
986- * Service Workers when using request interception by setting {@code Browser.newContext. serviceWorkers} to {@code "block"}.
986+ * Service Workers when using request interception by setting {@code serviceWorkers} to {@code "block"}.
987987 *
988988 * <p> <strong>Usage</strong>
989989 *
@@ -1037,7 +1037,7 @@ default void route(String url, Consumer<Route> handler) {
10371037 *
10381038 * <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
10391039 * Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
1040- * Service Workers when using request interception by setting {@code Browser.newContext. serviceWorkers} to {@code "block"}.
1040+ * Service Workers when using request interception by setting {@code serviceWorkers} to {@code "block"}.
10411041 *
10421042 * <p> <strong>Usage</strong>
10431043 *
@@ -1093,7 +1093,7 @@ default void route(Pattern url, Consumer<Route> handler) {
10931093 *
10941094 * <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
10951095 * Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
1096- * Service Workers when using request interception by setting {@code Browser.newContext. serviceWorkers} to {@code "block"}.
1096+ * Service Workers when using request interception by setting {@code serviceWorkers} to {@code "block"}.
10971097 *
10981098 * <p> <strong>Usage</strong>
10991099 *
@@ -1147,7 +1147,7 @@ default void route(Pattern url, Consumer<Route> handler) {
11471147 *
11481148 * <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
11491149 * Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
1150- * Service Workers when using request interception by setting {@code Browser.newContext. serviceWorkers} to {@code "block"}.
1150+ * Service Workers when using request interception by setting {@code serviceWorkers} to {@code "block"}.
11511151 *
11521152 * <p> <strong>Usage</strong>
11531153 *
@@ -1203,7 +1203,7 @@ default void route(Predicate<String> url, Consumer<Route> handler) {
12031203 *
12041204 * <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
12051205 * Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
1206- * Service Workers when using request interception by setting {@code Browser.newContext. serviceWorkers} to {@code "block"}.
1206+ * Service Workers when using request interception by setting {@code serviceWorkers} to {@code "block"}.
12071207 *
12081208 * <p> <strong>Usage</strong>
12091209 *
@@ -1257,7 +1257,7 @@ default void route(Predicate<String> url, Consumer<Route> handler) {
12571257 *
12581258 * <p> Playwright will not serve requests intercepted by Service Worker from the HAR file. See <a
12591259 * href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
1260- * using request interception by setting {@code Browser.newContext. serviceWorkers} to {@code "block"}.
1260+ * using request interception by setting {@code serviceWorkers} to {@code "block"}.
12611261 *
12621262 * @param har Path to a <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> file with prerecorded network data. If {@code
12631263 * path} is a relative path, then it is resolved relative to the current working directory.
@@ -1272,13 +1272,94 @@ default void routeFromHAR(Path har) {
12721272 *
12731273 * <p> Playwright will not serve requests intercepted by Service Worker from the HAR file. See <a
12741274 * href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
1275- * using request interception by setting {@code Browser.newContext. serviceWorkers} to {@code "block"}.
1275+ * using request interception by setting {@code serviceWorkers} to {@code "block"}.
12761276 *
12771277 * @param har Path to a <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> file with prerecorded network data. If {@code
12781278 * path} is a relative path, then it is resolved relative to the current working directory.
12791279 * @since v1.23
12801280 */
12811281 void routeFromHAR (Path har , RouteFromHAROptions options );
1282+ /**
1283+ * This method allows to modify websocket connections that are made by any page in the browser context.
1284+ *
1285+ * <p> Note that only {@code WebSocket}s created after this method was called will be routed. It is recommended to call this
1286+ * method before creating any pages.
1287+ *
1288+ * <p> <strong>Usage</strong>
1289+ *
1290+ * <p> Below is an example of a simple handler that blocks some websocket messages. See {@code WebSocketRoute} for more details
1291+ * and examples.
1292+ * <pre>{@code
1293+ * context.routeWebSocket("/ws", ws -> {
1294+ * ws.routeSend(message -> {
1295+ * if ("to-be-blocked".equals(message))
1296+ * return;
1297+ * ws.send(message);
1298+ * });
1299+ * ws.connect();
1300+ * });
1301+ * }</pre>
1302+ *
1303+ * @param url Only WebSockets with the url matching this pattern will be routed. A string pattern can be relative to the {@code
1304+ * baseURL} context option.
1305+ * @param handler Handler function to route the WebSocket.
1306+ * @since v1.48
1307+ */
1308+ void routeWebSocket (String url , Consumer <WebSocketRoute > handler );
1309+ /**
1310+ * This method allows to modify websocket connections that are made by any page in the browser context.
1311+ *
1312+ * <p> Note that only {@code WebSocket}s created after this method was called will be routed. It is recommended to call this
1313+ * method before creating any pages.
1314+ *
1315+ * <p> <strong>Usage</strong>
1316+ *
1317+ * <p> Below is an example of a simple handler that blocks some websocket messages. See {@code WebSocketRoute} for more details
1318+ * and examples.
1319+ * <pre>{@code
1320+ * context.routeWebSocket("/ws", ws -> {
1321+ * ws.routeSend(message -> {
1322+ * if ("to-be-blocked".equals(message))
1323+ * return;
1324+ * ws.send(message);
1325+ * });
1326+ * ws.connect();
1327+ * });
1328+ * }</pre>
1329+ *
1330+ * @param url Only WebSockets with the url matching this pattern will be routed. A string pattern can be relative to the {@code
1331+ * baseURL} context option.
1332+ * @param handler Handler function to route the WebSocket.
1333+ * @since v1.48
1334+ */
1335+ void routeWebSocket (Pattern url , Consumer <WebSocketRoute > handler );
1336+ /**
1337+ * This method allows to modify websocket connections that are made by any page in the browser context.
1338+ *
1339+ * <p> Note that only {@code WebSocket}s created after this method was called will be routed. It is recommended to call this
1340+ * method before creating any pages.
1341+ *
1342+ * <p> <strong>Usage</strong>
1343+ *
1344+ * <p> Below is an example of a simple handler that blocks some websocket messages. See {@code WebSocketRoute} for more details
1345+ * and examples.
1346+ * <pre>{@code
1347+ * context.routeWebSocket("/ws", ws -> {
1348+ * ws.routeSend(message -> {
1349+ * if ("to-be-blocked".equals(message))
1350+ * return;
1351+ * ws.send(message);
1352+ * });
1353+ * ws.connect();
1354+ * });
1355+ * }</pre>
1356+ *
1357+ * @param url Only WebSockets with the url matching this pattern will be routed. A string pattern can be relative to the {@code
1358+ * baseURL} context option.
1359+ * @param handler Handler function to route the WebSocket.
1360+ * @since v1.48
1361+ */
1362+ void routeWebSocket (Predicate <String > url , Consumer <WebSocketRoute > handler );
12821363 /**
12831364 * This setting will change the default maximum navigation time for the following methods and related shortcuts:
12841365 * <ul>
0 commit comments