playwright 1.62.1 → 1.65.0

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.
@@ -1,34 +1,33 @@
1
1
  # packages/playwright/lib/common/index.js
2
- # total: 114.2 KB
2
+ # total: 117.6 KB
3
3
 
4
4
  ## Inlined (20)
5
- 12.0 KB packages/playwright/src/common/config.ts
6
- 13.7 KB packages/playwright/src/common/configLoader.ts
5
+ 12.5 KB packages/playwright/src/common/config.ts
6
+ 13.8 KB packages/playwright/src/common/configLoader.ts
7
7
  11.5 KB packages/playwright/src/common/fixtures.ts
8
8
  0.8 KB packages/playwright/src/common/index.ts
9
9
  1.3 KB packages/playwright/src/common/ipc.ts
10
10
  2.1 KB packages/playwright/src/common/poolBuilder.ts
11
11
  3.9 KB packages/playwright/src/common/process.ts
12
- 4.7 KB packages/playwright/src/common/suiteUtils.ts
13
- 8.5 KB packages/playwright/src/common/test.ts
14
- 2.0 KB packages/playwright/src/common/testLoader.ts
15
- 12.6 KB packages/playwright/src/common/testType.ts
16
- 1.2 KB packages/playwright/src/common/validators.ts
12
+ 4.9 KB packages/playwright/src/common/suiteUtils.ts
13
+ 8.7 KB packages/playwright/src/common/test.ts
14
+ 2.1 KB packages/playwright/src/common/testLoader.ts
15
+ 13.0 KB packages/playwright/src/common/testType.ts
16
+ 1.4 KB packages/playwright/src/common/validators.ts
17
17
  1.3 KB packages/playwright/src/isomorphic/teleReceiver.ts
18
- 9.7 KB packages/playwright/src/transform/compilationCache.ts
19
- 1.7 KB packages/playwright/src/transform/esmLoaderSync.ts
18
+ 8.7 KB packages/playwright/src/transform/compilationCache.ts
19
+ 1.8 KB packages/playwright/src/transform/esmLoaderSync.ts
20
20
  1.1 KB packages/playwright/src/transform/pirates.ts
21
21
  1.1 KB packages/playwright/src/transform/portTransport.ts
22
- 12.3 KB packages/playwright/src/transform/transform.ts
23
- 2.9 KB packages/playwright/src/transform/tsconfig-loader.ts
22
+ 13.7 KB packages/playwright/src/transform/transform.ts
23
+ 4.2 KB packages/playwright/src/transform/tsconfig-loader.ts
24
24
  7.0 KB packages/playwright/src/util.ts
25
25
 
26
- ## External (8)
26
+ ## External (7)
27
27
  ../globals
28
28
  ../matchers/expect
29
29
  ../package
30
30
  ../transform/esmLoader.js
31
- playwright
32
31
  playwright-core/lib/bootstrap
33
32
  playwright-core/lib/coreBundle
34
33
  playwright-core/lib/utilsBundle
package/lib/index.js CHANGED
@@ -47,8 +47,7 @@ var import_browserBackend = require("./mcp/test/browserBackend");
47
47
  var import_expect = require("./matchers/expect");
48
48
  var import_common2 = require("./common");
49
49
  var import_expect2 = require("./matchers/expect");
50
- const { asLocatorDescription } = require("playwright-core/lib/coreBundle").iso;
51
- const { getActionGroup, renderTitleForCall } = require("playwright-core/lib/coreBundle").iso;
50
+ const { getActionGroup, renderParamsForCall, renderSubtitleForCall, renderTitleForCall, truncateParam } = require("playwright-core/lib/coreBundle").iso;
52
51
  const { escapeHTML } = require("playwright-core/lib/coreBundle").iso;
53
52
  const { jsonStringifyForceASCII } = require("playwright-core/lib/coreBundle").utils;
54
53
  const { createGuid } = require("playwright-core/lib/coreBundle").utils;
@@ -84,41 +83,37 @@ const utilityFixtures = {
84
83
  const csiListener = {
85
84
  onApiCallBegin: (data, channel) => {
86
85
  const testInfo2 = globals.currentTestInfo();
87
- if (!testInfo2 || data.apiName.includes("setTestIdAttribute") || data.apiName === "tracing.groupEnd")
86
+ if (!testInfo2)
88
87
  return;
88
+ if (channel.type === "Tracing" && channel.method === "tracingGroupEnd") {
89
+ data.userData = (error) => tracingGroupSteps.pop()?.complete({ error });
90
+ return;
91
+ }
89
92
  const zone = currentZone().data("stepZone");
90
- const isExpectCall = data.apiName === "locator._expect" || data.apiName === "frame._expect" || data.apiName === "page._expectScreenshot";
93
+ const isExpectCall = channel.type === "Frame" && channel.method === "expect" || channel.type === "Page" && channel.method === "expectScreenshot";
91
94
  if (zone && zone.category === "expect" && isExpectCall) {
92
- if (zone.apiName)
93
- data.apiName = zone.apiName;
94
- if (zone.shortTitle || zone.title)
95
- data.title = zone.shortTitle ?? zone.title;
96
- data.stepId = zone.stepId;
95
+ data.callId = zone.stepId;
97
96
  return;
98
97
  }
98
+ const params = renderParamsForCall({ type: channel.type, method: channel.method, params: channel.params });
99
99
  const step = testInfo2._addStep({
100
- location: data.frames[0],
100
+ stack: data.frames,
101
101
  category: "pw:api",
102
102
  title: renderTitle(channel.type, channel.method, channel.params, data.title),
103
- apiName: data.apiName,
104
- params: channel.params,
103
+ subtitle: renderSubtitle(channel.type, channel.method, channel.params),
104
+ params,
105
105
  group: getActionGroup({ type: channel.type, method: channel.method })
106
106
  }, tracingGroupSteps[tracingGroupSteps.length - 1]);
107
- data.userData = step;
108
- data.stepId = step.stepId;
109
- if (data.apiName === "tracing.group")
107
+ data.callId = step.stepId;
108
+ if (channel.type === "Tracing" && channel.method === "tracingGroup") {
110
109
  tracingGroupSteps.push(step);
110
+ } else {
111
+ data.userData = (error) => step.complete({ error });
112
+ }
111
113
  },
112
114
  onApiCallEnd: (data) => {
113
- if (data.apiName === "tracing.group")
114
- return;
115
- if (data.apiName === "tracing.groupEnd") {
116
- const step2 = tracingGroupSteps.pop();
117
- step2?.complete({ error: data.error });
118
- return;
119
- }
120
- const step = data.userData;
121
- step?.complete({ error: data.error });
115
+ const completeStep = data.userData;
116
+ completeStep?.(data.error);
122
117
  },
123
118
  onWillPause: ({ keepTestTimeout }) => {
124
119
  if (!keepTestTimeout)
@@ -239,8 +234,10 @@ const playwrightFixtures = {
239
234
  acceptDownloads: [({ contextOptions }, use) => use(contextOptions.acceptDownloads ?? true), { option: true, box: true }],
240
235
  bypassCSP: [({ contextOptions }, use) => use(contextOptions.bypassCSP ?? false), { option: true, box: true }],
241
236
  colorScheme: [({ contextOptions }, use) => use(contextOptions.colorScheme === void 0 ? "light" : contextOptions.colorScheme), { option: true, box: true }],
237
+ contrast: [({ contextOptions }, use) => use(contextOptions.contrast === void 0 ? "no-preference" : contextOptions.contrast), { option: true, box: true }],
242
238
  deviceScaleFactor: [({ contextOptions }, use) => use(contextOptions.deviceScaleFactor), { option: true, box: true }],
243
239
  extraHTTPHeaders: [({ contextOptions }, use) => use(contextOptions.extraHTTPHeaders), { option: true, box: true }],
240
+ forcedColors: [({ contextOptions }, use) => use(contextOptions.forcedColors === void 0 ? "none" : contextOptions.forcedColors), { option: true, box: true }],
244
241
  geolocation: [({ contextOptions }, use) => use(contextOptions.geolocation), { option: true, box: true }],
245
242
  hasTouch: [({ contextOptions }, use) => use(contextOptions.hasTouch ?? false), { option: true, box: true }],
246
243
  httpCredentials: [({ contextOptions }, use) => use(contextOptions.httpCredentials), { option: true, box: true }],
@@ -251,6 +248,8 @@ const playwrightFixtures = {
251
248
  offline: [({ contextOptions }, use) => use(contextOptions.offline ?? false), { option: true, box: true }],
252
249
  permissions: [({ contextOptions }, use) => use(contextOptions.permissions), { option: true, box: true }],
253
250
  proxy: [({ contextOptions }, use) => use(contextOptions.proxy), { option: true, box: true }],
251
+ reducedMotion: [({ contextOptions }, use) => use(contextOptions.reducedMotion === void 0 ? "no-preference" : contextOptions.reducedMotion), { option: true, box: true }],
252
+ screen: [({ contextOptions }, use) => use(contextOptions.screen), { option: true, box: true }],
254
253
  storageState: [({ contextOptions }, use) => use(contextOptions.storageState), { option: true, box: true }],
255
254
  clientCertificates: [({ contextOptions }, use) => use(contextOptions.clientCertificates), { option: true, box: true }],
256
255
  timezoneId: [({ contextOptions }, use) => use(contextOptions.timezoneId), { option: true, box: true }],
@@ -268,8 +267,10 @@ const playwrightFixtures = {
268
267
  bypassCSP,
269
268
  clientCertificates,
270
269
  colorScheme,
270
+ contrast,
271
271
  deviceScaleFactor,
272
272
  extraHTTPHeaders,
273
+ forcedColors,
273
274
  hasTouch,
274
275
  geolocation,
275
276
  httpCredentials,
@@ -280,6 +281,8 @@ const playwrightFixtures = {
280
281
  offline,
281
282
  permissions,
282
283
  proxy,
284
+ reducedMotion,
285
+ screen,
283
286
  storageState,
284
287
  viewport,
285
288
  timezoneId,
@@ -295,10 +298,14 @@ const playwrightFixtures = {
295
298
  options.bypassCSP = bypassCSP;
296
299
  if (colorScheme !== void 0)
297
300
  options.colorScheme = colorScheme;
301
+ if (contrast !== void 0)
302
+ options.contrast = contrast;
298
303
  if (deviceScaleFactor !== void 0)
299
304
  options.deviceScaleFactor = deviceScaleFactor;
300
305
  if (extraHTTPHeaders !== void 0)
301
306
  options.extraHTTPHeaders = extraHTTPHeaders;
307
+ if (forcedColors !== void 0)
308
+ options.forcedColors = forcedColors;
302
309
  if (geolocation !== void 0)
303
310
  options.geolocation = geolocation;
304
311
  if (hasTouch !== void 0)
@@ -319,6 +326,10 @@ const playwrightFixtures = {
319
326
  options.permissions = permissions;
320
327
  if (proxy !== void 0)
321
328
  options.proxy = proxy;
329
+ if (reducedMotion !== void 0)
330
+ options.reducedMotion = reducedMotion;
331
+ if (screen !== void 0)
332
+ options.screen = screen;
322
333
  if (storageState !== void 0)
323
334
  options.storageState = storageState;
324
335
  if (clientCertificates?.length)
@@ -378,6 +389,7 @@ const playwrightFixtures = {
378
389
  recordVideo: {
379
390
  dir: tracing().artifactsDir(),
380
391
  size: typeof video === "string" ? void 0 : video.size,
392
+ fps: typeof video === "string" ? void 0 : video.fps,
381
393
  showActions: show?.actions
382
394
  }
383
395
  } : {};
@@ -640,6 +652,7 @@ class ArtifactsRecorder {
640
652
  }
641
653
  async didCreateBrowserContext(context) {
642
654
  await this._startTraceChunkOnContextCreation(context, context.tracing);
655
+ await this._startTraceChunkOnContextCreation(context.request, context.request.tracing);
643
656
  }
644
657
  async willCloseBrowserContext(context) {
645
658
  await this._stopTracing(context, context.tracing);
@@ -680,6 +693,7 @@ class ArtifactsRecorder {
680
693
  const leftoverContexts = this._playwright._allContexts();
681
694
  const leftoverApiRequests = Array.from(this._playwright.request._contexts);
682
695
  await Promise.all(leftoverContexts.map(async (context2) => {
696
+ await this._stopTracing(context2.request, context2.request.tracing);
683
697
  await this._stopTracing(context2, context2.tracing);
684
698
  }).concat(leftoverApiRequests.map(async (context2) => {
685
699
  await this._stopTracing(context2, context2.tracing);
@@ -746,7 +760,7 @@ async function installScreencastTitleUpdater(testInfo, context, testAnnotate) {
746
760
  const position = testAnnotate.position ?? "top-left";
747
761
  const fontSize = testAnnotate.fontSize ?? 14;
748
762
  const level = testAnnotate.level ?? "step";
749
- const updateOverlay = async () => {
763
+ const doUpdateOverlay = async () => {
750
764
  const parts = level === "step" ? [...testTitle, ...stepStack] : testTitle;
751
765
  const html = createTestOverlay(parts, position, fontSize);
752
766
  for (const page of context.pages()) {
@@ -756,6 +770,13 @@ async function installScreencastTitleUpdater(testInfo, context, testAnnotate) {
756
770
  overlays.set(page, disposable);
757
771
  }
758
772
  };
773
+ let lastUpdate = Promise.resolve();
774
+ const updateOverlay = () => {
775
+ const result = lastUpdate.then(doUpdateOverlay);
776
+ lastUpdate = result.catch(() => {
777
+ });
778
+ return result;
779
+ };
759
780
  testInfo._onUserStepBegin = async (title) => {
760
781
  stepStack.push(title);
761
782
  await updateOverlay();
@@ -784,11 +805,11 @@ function createTestOverlay(parts, position, fontSize) {
784
805
  </div>`;
785
806
  }
786
807
  function renderTitle(type, method, params, title) {
787
- const prefix = renderTitleForCall({ title, type, method, params });
788
- let selector;
789
- if (params?.["selector"] && typeof params.selector === "string")
790
- selector = asLocatorDescription("javascript", params.selector);
791
- return prefix + (selector ? ` ${selector}` : "");
808
+ return renderTitleForCall({ title, type, method, params });
809
+ }
810
+ function renderSubtitle(type, method, params) {
811
+ const subtitle = renderSubtitleForCall({ type, method, params });
812
+ return subtitle === void 0 ? void 0 : truncateParam(subtitle);
792
813
  }
793
814
  function tracing() {
794
815
  return test.info()._tracing;