@@ -927,7 +927,7 @@ default void grantPermissions(List<String> permissions) {
927
927
*
928
928
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
929
929
* 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"}.
931
931
*
932
932
* <p> <strong>Usage</strong>
933
933
*
@@ -983,7 +983,7 @@ default void route(String url, Consumer<Route> handler) {
983
983
*
984
984
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
985
985
* 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"}.
987
987
*
988
988
* <p> <strong>Usage</strong>
989
989
*
@@ -1037,7 +1037,7 @@ default void route(String url, Consumer<Route> handler) {
1037
1037
*
1038
1038
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
1039
1039
* 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"}.
1041
1041
*
1042
1042
* <p> <strong>Usage</strong>
1043
1043
*
@@ -1093,7 +1093,7 @@ default void route(Pattern url, Consumer<Route> handler) {
1093
1093
*
1094
1094
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
1095
1095
* 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"}.
1097
1097
*
1098
1098
* <p> <strong>Usage</strong>
1099
1099
*
@@ -1147,7 +1147,7 @@ default void route(Pattern url, Consumer<Route> handler) {
1147
1147
*
1148
1148
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
1149
1149
* 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"}.
1151
1151
*
1152
1152
* <p> <strong>Usage</strong>
1153
1153
*
@@ -1203,7 +1203,7 @@ default void route(Predicate<String> url, Consumer<Route> handler) {
1203
1203
*
1204
1204
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
1205
1205
* 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"}.
1207
1207
*
1208
1208
* <p> <strong>Usage</strong>
1209
1209
*
@@ -1257,7 +1257,7 @@ default void route(Predicate<String> url, Consumer<Route> handler) {
1257
1257
*
1258
1258
* <p> Playwright will not serve requests intercepted by Service Worker from the HAR file. See <a
1259
1259
* 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"}.
1261
1261
*
1262
1262
* @param har Path to a <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> file with prerecorded network data. If {@code
1263
1263
* path} is a relative path, then it is resolved relative to the current working directory.
@@ -1272,13 +1272,94 @@ default void routeFromHAR(Path har) {
1272
1272
*
1273
1273
* <p> Playwright will not serve requests intercepted by Service Worker from the HAR file. See <a
1274
1274
* 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"}.
1276
1276
*
1277
1277
* @param har Path to a <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> file with prerecorded network data. If {@code
1278
1278
* path} is a relative path, then it is resolved relative to the current working directory.
1279
1279
* @since v1.23
1280
1280
*/
1281
1281
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 );
1282
1363
/**
1283
1364
* This setting will change the default maximum navigation time for the following methods and related shortcuts:
1284
1365
* <ul>
0 commit comments