playwright-core 1.55.0-alpha-2025-08-07 → 1.55.0-alpha-2025-08-09

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -212,7 +212,7 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
212
212
  this._routes.splice(index, 1);
213
213
  const handled = await routeHandler.handle(route);
214
214
  if (!this._routes.length)
215
- this._updateInterceptionPatterns().catch(() => {
215
+ this._updateInterceptionPatterns({ internal: true }).catch(() => {
216
216
  });
217
217
  if (handled)
218
218
  return;
@@ -310,11 +310,11 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
310
310
  }
311
311
  async route(url, handler, options = {}) {
312
312
  this._routes.unshift(new network.RouteHandler(this._platform, this._options.baseURL, url, handler, options.times));
313
- await this._updateInterceptionPatterns();
313
+ await this._updateInterceptionPatterns({ title: "Route requests" });
314
314
  }
315
315
  async routeWebSocket(url, handler) {
316
316
  this._webSocketRoutes.unshift(new network.WebSocketRouteHandler(this._options.baseURL, url, handler));
317
- await this._updateWebSocketInterceptionPatterns();
317
+ await this._updateWebSocketInterceptionPatterns({ title: "Route WebSockets" });
318
318
  }
319
319
  async _recordIntoHAR(har, page, options = {}) {
320
320
  const { harId } = await this._channel.harStart({
@@ -367,15 +367,15 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
367
367
  const promises = removed.map((routeHandler) => routeHandler.stop(behavior));
368
368
  await Promise.all(promises);
369
369
  }
370
- await this._updateInterceptionPatterns();
370
+ await this._updateInterceptionPatterns({ title: "Unroute requests" });
371
371
  }
372
- async _updateInterceptionPatterns() {
372
+ async _updateInterceptionPatterns(options) {
373
373
  const patterns = network.RouteHandler.prepareInterceptionPatterns(this._routes);
374
- await this._channel.setNetworkInterceptionPatterns({ patterns });
374
+ await this._wrapApiCall(() => this._channel.setNetworkInterceptionPatterns({ patterns }), options);
375
375
  }
376
- async _updateWebSocketInterceptionPatterns() {
376
+ async _updateWebSocketInterceptionPatterns(options) {
377
377
  const patterns = network.WebSocketRouteHandler.prepareInterceptionPatterns(this._webSocketRoutes);
378
- await this._channel.setWebSocketInterceptionPatterns({ patterns });
378
+ await this._wrapApiCall(() => this._channel.setWebSocketInterceptionPatterns({ patterns }), options);
379
379
  }
380
380
  _effectiveCloseReason() {
381
381
  return this._closeReason || this._browser?._closeReason;
@@ -144,7 +144,7 @@ class Page extends import_channelOwner.ChannelOwner {
144
144
  this._routes.splice(index, 1);
145
145
  const handled = await routeHandler.handle(route);
146
146
  if (!this._routes.length)
147
- this._updateInterceptionPatterns().catch(() => {
147
+ this._updateInterceptionPatterns({ internal: true }).catch(() => {
148
148
  });
149
149
  if (handled)
150
150
  return;
@@ -406,7 +406,7 @@ class Page extends import_channelOwner.ChannelOwner {
406
406
  }
407
407
  async route(url, handler, options = {}) {
408
408
  this._routes.unshift(new import_network.RouteHandler(this._platform, this._browserContext._options.baseURL, url, handler, options.times));
409
- await this._updateInterceptionPatterns();
409
+ await this._updateInterceptionPatterns({ title: "Route requests" });
410
410
  }
411
411
  async routeFromHAR(har, options = {}) {
412
412
  const localUtils = this._connection.localUtils();
@@ -422,7 +422,7 @@ class Page extends import_channelOwner.ChannelOwner {
422
422
  }
423
423
  async routeWebSocket(url, handler) {
424
424
  this._webSocketRoutes.unshift(new import_network.WebSocketRouteHandler(this._browserContext._options.baseURL, url, handler));
425
- await this._updateWebSocketInterceptionPatterns();
425
+ await this._updateWebSocketInterceptionPatterns({ title: "Route WebSockets" });
426
426
  }
427
427
  _disposeHarRouters() {
428
428
  this._harRouters.forEach((router) => router.dispose());
@@ -449,15 +449,15 @@ class Page extends import_channelOwner.ChannelOwner {
449
449
  const promises = removed.map((routeHandler) => routeHandler.stop(behavior));
450
450
  await Promise.all(promises);
451
451
  }
452
- await this._updateInterceptionPatterns();
452
+ await this._updateInterceptionPatterns({ title: "Unroute requests" });
453
453
  }
454
- async _updateInterceptionPatterns() {
454
+ async _updateInterceptionPatterns(options) {
455
455
  const patterns = import_network.RouteHandler.prepareInterceptionPatterns(this._routes);
456
- await this._channel.setNetworkInterceptionPatterns({ patterns });
456
+ await this._wrapApiCall(() => this._channel.setNetworkInterceptionPatterns({ patterns }), options);
457
457
  }
458
- async _updateWebSocketInterceptionPatterns() {
458
+ async _updateWebSocketInterceptionPatterns(options) {
459
459
  const patterns = import_network.WebSocketRouteHandler.prepareInterceptionPatterns(this._webSocketRoutes);
460
- await this._channel.setWebSocketInterceptionPatterns({ patterns });
460
+ await this._wrapApiCall(() => this._channel.setWebSocketInterceptionPatterns({ patterns }), options);
461
461
  }
462
462
  async screenshot(options = {}) {
463
463
  const mask = options.mask;
@@ -33,19 +33,23 @@ class Tracing extends import_channelOwner.ChannelOwner {
33
33
  return channel._object;
34
34
  }
35
35
  async start(options = {}) {
36
- this._includeSources = !!options.sources;
37
- await this._channel.tracingStart({
38
- name: options.name,
39
- snapshots: options.snapshots,
40
- screenshots: options.screenshots,
41
- live: options._live
36
+ await this._wrapApiCall(async () => {
37
+ this._includeSources = !!options.sources;
38
+ await this._channel.tracingStart({
39
+ name: options.name,
40
+ snapshots: options.snapshots,
41
+ screenshots: options.screenshots,
42
+ live: options._live
43
+ });
44
+ const { traceName } = await this._channel.tracingStartChunk({ name: options.name, title: options.title });
45
+ await this._startCollectingStacks(traceName);
42
46
  });
43
- const { traceName } = await this._channel.tracingStartChunk({ name: options.name, title: options.title });
44
- await this._startCollectingStacks(traceName);
45
47
  }
46
48
  async startChunk(options = {}) {
47
- const { traceName } = await this._channel.tracingStartChunk(options);
48
- await this._startCollectingStacks(traceName);
49
+ await this._wrapApiCall(async () => {
50
+ const { traceName } = await this._channel.tracingStartChunk(options);
51
+ await this._startCollectingStacks(traceName);
52
+ });
49
53
  }
50
54
  async group(name, options = {}) {
51
55
  await this._channel.tracingGroup({ name, location: options.location });
@@ -62,11 +66,15 @@ class Tracing extends import_channelOwner.ChannelOwner {
62
66
  this._stacksId = result?.stacksId;
63
67
  }
64
68
  async stopChunk(options = {}) {
65
- await this._doStopChunk(options.path);
69
+ await this._wrapApiCall(async () => {
70
+ await this._doStopChunk(options.path);
71
+ });
66
72
  }
67
73
  async stop(options = {}) {
68
- await this._doStopChunk(options.path);
69
- await this._channel.tracingStop();
74
+ await this._wrapApiCall(async () => {
75
+ await this._doStopChunk(options.path);
76
+ await this._channel.tracingStop();
77
+ });
70
78
  }
71
79
  async _doStopChunk(filePath) {
72
80
  this._resetStackCounter();