playwright-core 1.54.0-alpha-2025-06-12 → 1.54.0-alpha-2025-06-14

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.
Files changed (31) hide show
  1. package/browsers.json +11 -11
  2. package/lib/browserServerImpl.js +24 -1
  3. package/lib/generated/injectedScriptSource.js +1 -1
  4. package/lib/server/bidi/bidiInput.js +19 -16
  5. package/lib/server/bidi/bidiPage.js +1 -1
  6. package/lib/server/browserContext.js +12 -7
  7. package/lib/server/chromium/crBrowser.js +2 -1
  8. package/lib/server/chromium/crDragDrop.js +7 -2
  9. package/lib/server/chromium/crInput.js +21 -11
  10. package/lib/server/chromium/crPage.js +2 -2
  11. package/lib/server/deviceDescriptorsSource.json +54 -54
  12. package/lib/server/dispatchers/androidDispatcher.js +4 -2
  13. package/lib/server/dispatchers/pageDispatcher.js +17 -12
  14. package/lib/server/dom.js +10 -11
  15. package/lib/server/firefox/ffInput.js +16 -8
  16. package/lib/server/firefox/ffPage.js +2 -2
  17. package/lib/server/frames.js +7 -7
  18. package/lib/server/input.js +91 -52
  19. package/lib/server/launchApp.js +1 -1
  20. package/lib/server/page.js +5 -5
  21. package/lib/server/recorder/recorderRunner.js +1 -1
  22. package/lib/server/webkit/wkInput.js +17 -8
  23. package/lib/server/webkit/wkPage.js +1 -1
  24. package/lib/vite/traceViewer/assets/{codeMirrorModule-BKr-mZ2D.js → codeMirrorModule-CgepVw_3.js} +1 -1
  25. package/lib/vite/traceViewer/assets/{defaultSettingsView-CzQxXsO4.js → defaultSettingsView-3fKvgZ5q.js} +77 -77
  26. package/lib/vite/traceViewer/{index.BT-45kLv.js → index.B3b5SgUS.js} +1 -1
  27. package/lib/vite/traceViewer/index.html +2 -2
  28. package/lib/vite/traceViewer/{uiMode.BuGgfvGl.js → uiMode.D35cTLb_.js} +1 -1
  29. package/lib/vite/traceViewer/uiMode.html +2 -2
  30. package/package.json +1 -1
  31. package/types/types.d.ts +1 -0
@@ -43,28 +43,28 @@ class RawKeyboardImpl {
43
43
  setSession(session) {
44
44
  this._session = session;
45
45
  }
46
- async keydown(modifiers, keyName, description, autoRepeat) {
46
+ async keydown(progress, modifiers, keyName, description, autoRepeat) {
47
47
  keyName = (0, import_input.resolveSmartModifierString)(keyName);
48
48
  const actions = [];
49
49
  actions.push({ type: "keyDown", value: (0, import_bidiKeyboard.getBidiKeyValue)(keyName) });
50
- await this._performActions(actions);
50
+ await this._performActions(progress, actions);
51
51
  }
52
- async keyup(modifiers, keyName, description) {
52
+ async keyup(progress, modifiers, keyName, description) {
53
53
  keyName = (0, import_input.resolveSmartModifierString)(keyName);
54
54
  const actions = [];
55
55
  actions.push({ type: "keyUp", value: (0, import_bidiKeyboard.getBidiKeyValue)(keyName) });
56
- await this._performActions(actions);
56
+ await this._performActions(progress, actions);
57
57
  }
58
- async sendText(text) {
58
+ async sendText(progress, text) {
59
59
  const actions = [];
60
60
  for (const char of text) {
61
61
  const value = (0, import_bidiKeyboard.getBidiKeyValue)(char);
62
62
  actions.push({ type: "keyDown", value });
63
63
  actions.push({ type: "keyUp", value });
64
64
  }
65
- await this._performActions(actions);
65
+ await this._performActions(progress, actions);
66
66
  }
67
- async _performActions(actions) {
67
+ async _performActions(progress, actions) {
68
68
  await this._session.send("input.performActions", {
69
69
  context: this._session.sessionId,
70
70
  actions: [
@@ -75,22 +75,23 @@ class RawKeyboardImpl {
75
75
  }
76
76
  ]
77
77
  });
78
+ progress.throwIfAborted();
78
79
  }
79
80
  }
80
81
  class RawMouseImpl {
81
82
  constructor(session) {
82
83
  this._session = session;
83
84
  }
84
- async move(x, y, button, buttons, modifiers, forClick) {
85
- await this._performActions([{ type: "pointerMove", x, y }]);
85
+ async move(progress, x, y, button, buttons, modifiers, forClick) {
86
+ await this._performActions(progress, [{ type: "pointerMove", x, y }]);
86
87
  }
87
- async down(x, y, button, buttons, modifiers, clickCount) {
88
- await this._performActions([{ type: "pointerDown", button: toBidiButton(button) }]);
88
+ async down(progress, x, y, button, buttons, modifiers, clickCount) {
89
+ await this._performActions(progress, [{ type: "pointerDown", button: toBidiButton(button) }]);
89
90
  }
90
- async up(x, y, button, buttons, modifiers, clickCount) {
91
- await this._performActions([{ type: "pointerUp", button: toBidiButton(button) }]);
91
+ async up(progress, x, y, button, buttons, modifiers, clickCount) {
92
+ await this._performActions(progress, [{ type: "pointerUp", button: toBidiButton(button) }]);
92
93
  }
93
- async wheel(x, y, buttons, modifiers, deltaX, deltaY) {
94
+ async wheel(progress, x, y, buttons, modifiers, deltaX, deltaY) {
94
95
  x = Math.floor(x);
95
96
  y = Math.floor(y);
96
97
  await this._session.send("input.performActions", {
@@ -103,8 +104,9 @@ class RawMouseImpl {
103
104
  }
104
105
  ]
105
106
  });
107
+ progress.throwIfAborted();
106
108
  }
107
- async _performActions(actions) {
109
+ async _performActions(progress, actions) {
108
110
  await this._session.send("input.performActions", {
109
111
  context: this._session.sessionId,
110
112
  actions: [
@@ -118,13 +120,14 @@ class RawMouseImpl {
118
120
  }
119
121
  ]
120
122
  });
123
+ progress.throwIfAborted();
121
124
  }
122
125
  }
123
126
  class RawTouchscreenImpl {
124
127
  constructor(session) {
125
128
  this._session = session;
126
129
  }
127
- async tap(x, y, modifiers) {
130
+ async tap(progress, x, y, modifiers) {
128
131
  }
129
132
  }
130
133
  function toBidiButton(button) {
@@ -458,7 +458,7 @@ class BidiPage {
458
458
  }
459
459
  async inputActionEpilogue() {
460
460
  }
461
- async resetForReuse() {
461
+ async resetForReuse(progress) {
462
462
  }
463
463
  async pdf(options) {
464
464
  return this._pdf.generate(options);
@@ -55,6 +55,7 @@ var import_recorderApp = require("./recorder/recorderApp");
55
55
  var import_selectors = require("./selectors");
56
56
  var import_tracing = require("./trace/recorder/tracing");
57
57
  var rawStorageSource = __toESM(require("../generated/storageScriptSource"));
58
+ var import_progress = require("./progress");
58
59
  class BrowserContext extends import_instrumentation.SdkObject {
59
60
  constructor(browser, options, browserContextId) {
60
61
  super(browser, "browser-context");
@@ -160,6 +161,10 @@ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { co
160
161
  return JSON.stringify(paramsCopy);
161
162
  }
162
163
  async resetForReuse(metadata, params) {
164
+ const controller = new import_progress.ProgressController(metadata, this);
165
+ return controller.run((progress) => this.resetForReuseImpl(progress, params));
166
+ }
167
+ async resetForReuseImpl(progress, params) {
163
168
  await this.tracing.resetForReuse();
164
169
  if (params) {
165
170
  for (const key of paramsThatAllowContextReuse)
@@ -170,12 +175,12 @@ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { co
170
175
  let page = this.pages()[0];
171
176
  const [, ...otherPages] = this.pages();
172
177
  for (const p of otherPages)
173
- await p.close(metadata);
178
+ await p.close();
174
179
  if (page && page.hasCrashed()) {
175
- await page.close(metadata);
180
+ await page.close();
176
181
  page = void 0;
177
182
  }
178
- await page?.mainFrame().goto(metadata, "about:blank", { timeout: 0 });
183
+ await page?.mainFrame().gotoImpl(progress, "about:blank", {});
179
184
  await this._resetStorage();
180
185
  await this.clock.resetForReuse();
181
186
  if (this._options.permissions)
@@ -188,7 +193,7 @@ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { co
188
193
  await this.setUserAgent(this._options.userAgent);
189
194
  await this.clearCache();
190
195
  await this._resetCookies();
191
- await page?.resetForReuse(metadata);
196
+ await page?.resetForReuse(progress);
192
197
  }
193
198
  _browserClosed() {
194
199
  for (const page of this.pages())
@@ -312,7 +317,7 @@ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { co
312
317
  const browserName = this._browser.options.name;
313
318
  if (this._options.isMobile && browserName === "chromium" || this._options.locale && browserName === "webkit") {
314
319
  await this.newPage(progress.metadata);
315
- await defaultPage.close(progress.metadata);
320
+ await defaultPage.close();
316
321
  }
317
322
  }
318
323
  _authenticateProxyViaHeader() {
@@ -449,7 +454,7 @@ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { co
449
454
  if (storage.localStorage.length || storage.indexedDB?.length)
450
455
  result.origins.push({ origin, localStorage: storage.localStorage, indexedDB: storage.indexedDB });
451
456
  }
452
- await page.close(internalMetadata);
457
+ await page.close();
453
458
  }
454
459
  return result;
455
460
  }
@@ -510,7 +515,7 @@ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { co
510
515
  })()`;
511
516
  await frame.evaluateExpression(restoreScript, { world: "utility" });
512
517
  }
513
- await page.close(internalMetadata);
518
+ await page.close();
514
519
  }
515
520
  } finally {
516
521
  this._settingStorageState = false;
@@ -398,7 +398,8 @@ class CRBrowserContext extends import_browserContext.BrowserContext {
398
398
  ["payment-handler", "paymentHandler"],
399
399
  // chrome-specific permissions we have.
400
400
  ["midi-sysex", "midiSysex"],
401
- ["storage-access", "storageAccess"]
401
+ ["storage-access", "storageAccess"],
402
+ ["local-fonts", "localFonts"]
402
403
  ]);
403
404
  const filtered = permissions.map((permission) => {
404
405
  const protocolPermission = webPermissionToProtocol.get(permission);
@@ -44,7 +44,7 @@ class DragManager {
44
44
  this._dragState = null;
45
45
  return true;
46
46
  }
47
- async interceptDragCausedByMove(x, y, button, buttons, modifiers, moveCallback) {
47
+ async interceptDragCausedByMove(progress, x, y, button, buttons, modifiers, moveCallback) {
48
48
  this._lastPosition = { x, y };
49
49
  if (this._dragState) {
50
50
  await this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
@@ -54,6 +54,7 @@ class DragManager {
54
54
  data: this._dragState,
55
55
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers)
56
56
  });
57
+ progress.throwIfAborted();
57
58
  return;
58
59
  }
59
60
  if (button !== "left")
@@ -81,6 +82,7 @@ class DragManager {
81
82
  };
82
83
  }
83
84
  await this._crPage._page.safeNonStallingEvaluateInAllFrames(`(${setupDragListeners.toString()})()`, "utility");
85
+ progress.cleanupWhenAborted(() => this._crPage._page.safeNonStallingEvaluateInAllFrames("window.__cleanupDrag && window.__cleanupDrag()", "utility"));
84
86
  client.on("Input.dragIntercepted", onDragIntercepted);
85
87
  try {
86
88
  await client.send("Input.setInterceptDrags", { enabled: true });
@@ -95,6 +97,7 @@ class DragManager {
95
97
  this._dragState = expectingDrag ? (await dragInterceptedPromise).data : null;
96
98
  client.off("Input.dragIntercepted", onDragIntercepted);
97
99
  await client.send("Input.setInterceptDrags", { enabled: false });
100
+ progress.throwIfAborted();
98
101
  if (this._dragState) {
99
102
  await this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
100
103
  type: "dragEnter",
@@ -103,12 +106,13 @@ class DragManager {
103
106
  data: this._dragState,
104
107
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers)
105
108
  });
109
+ progress.throwIfAborted();
106
110
  }
107
111
  }
108
112
  isDragging() {
109
113
  return !!this._dragState;
110
114
  }
111
- async drop(x, y, modifiers) {
115
+ async drop(progress, x, y, modifiers) {
112
116
  (0, import_utils.assert)(this._dragState, "missing drag state");
113
117
  await this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
114
118
  type: "drop",
@@ -118,6 +122,7 @@ class DragManager {
118
122
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers)
119
123
  });
120
124
  this._dragState = null;
125
+ progress.throwIfAborted();
121
126
  }
122
127
  }
123
128
  // Annotate the CommonJS export names for ESM import in node:
@@ -59,10 +59,11 @@ class RawKeyboardImpl {
59
59
  commands = commands.filter((x) => !x.startsWith("insert"));
60
60
  return commands.map((c) => c.substring(0, c.length - 1));
61
61
  }
62
- async keydown(modifiers, keyName, description, autoRepeat) {
62
+ async keydown(progress, modifiers, keyName, description, autoRepeat) {
63
63
  const { code, key, location, text } = description;
64
64
  if (code === "Escape" && await this._dragManger.cancelDrag())
65
65
  return;
66
+ progress.throwIfAborted();
66
67
  const commands = this._commandsForCode(code, modifiers);
67
68
  await this._client.send("Input.dispatchKeyEvent", {
68
69
  type: text ? "keyDown" : "rawKeyDown",
@@ -77,8 +78,9 @@ class RawKeyboardImpl {
77
78
  location,
78
79
  isKeypad: location === input.keypadLocation
79
80
  });
81
+ progress.throwIfAborted();
80
82
  }
81
- async keyup(modifiers, keyName, description) {
83
+ async keyup(progress, modifiers, keyName, description) {
82
84
  const { code, key, location } = description;
83
85
  await this._client.send("Input.dispatchKeyEvent", {
84
86
  type: "keyUp",
@@ -88,9 +90,11 @@ class RawKeyboardImpl {
88
90
  code,
89
91
  location
90
92
  });
93
+ progress.throwIfAborted();
91
94
  }
92
- async sendText(text) {
95
+ async sendText(progress, text) {
93
96
  await this._client.send("Input.insertText", { text });
97
+ progress.throwIfAborted();
94
98
  }
95
99
  }
96
100
  class RawMouseImpl {
@@ -99,7 +103,7 @@ class RawMouseImpl {
99
103
  this._client = client;
100
104
  this._dragManager = dragManager;
101
105
  }
102
- async move(x, y, button, buttons, modifiers, forClick) {
106
+ async move(progress, x, y, button, buttons, modifiers, forClick) {
103
107
  const actualMove = async () => {
104
108
  await this._client.send("Input.dispatchMouseEvent", {
105
109
  type: "mouseMoved",
@@ -112,11 +116,13 @@ class RawMouseImpl {
112
116
  });
113
117
  };
114
118
  if (forClick) {
115
- return actualMove();
119
+ await actualMove();
120
+ progress.throwIfAborted();
121
+ return;
116
122
  }
117
- await this._dragManager.interceptDragCausedByMove(x, y, button, buttons, modifiers, actualMove);
123
+ await this._dragManager.interceptDragCausedByMove(progress, x, y, button, buttons, modifiers, actualMove);
118
124
  }
119
- async down(x, y, button, buttons, modifiers, clickCount) {
125
+ async down(progress, x, y, button, buttons, modifiers, clickCount) {
120
126
  if (this._dragManager.isDragging())
121
127
  return;
122
128
  await this._client.send("Input.dispatchMouseEvent", {
@@ -129,10 +135,11 @@ class RawMouseImpl {
129
135
  clickCount,
130
136
  force: buttons.size > 0 ? 0.5 : 0
131
137
  });
138
+ progress.throwIfAborted();
132
139
  }
133
- async up(x, y, button, buttons, modifiers, clickCount) {
140
+ async up(progress, x, y, button, buttons, modifiers, clickCount) {
134
141
  if (this._dragManager.isDragging()) {
135
- await this._dragManager.drop(x, y, modifiers);
142
+ await this._dragManager.drop(progress, x, y, modifiers);
136
143
  return;
137
144
  }
138
145
  await this._client.send("Input.dispatchMouseEvent", {
@@ -144,8 +151,9 @@ class RawMouseImpl {
144
151
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
145
152
  clickCount
146
153
  });
154
+ progress.throwIfAborted();
147
155
  }
148
- async wheel(x, y, buttons, modifiers, deltaX, deltaY) {
156
+ async wheel(progress, x, y, buttons, modifiers, deltaX, deltaY) {
149
157
  await this._client.send("Input.dispatchMouseEvent", {
150
158
  type: "mouseWheel",
151
159
  x,
@@ -154,13 +162,14 @@ class RawMouseImpl {
154
162
  deltaX,
155
163
  deltaY
156
164
  });
165
+ progress.throwIfAborted();
157
166
  }
158
167
  }
159
168
  class RawTouchscreenImpl {
160
169
  constructor(client) {
161
170
  this._client = client;
162
171
  }
163
- async tap(x, y, modifiers) {
172
+ async tap(progress, x, y, modifiers) {
164
173
  await Promise.all([
165
174
  this._client.send("Input.dispatchTouchEvent", {
166
175
  type: "touchStart",
@@ -176,6 +185,7 @@ class RawTouchscreenImpl {
176
185
  touchPoints: []
177
186
  })
178
187
  ]);
188
+ progress.throwIfAborted();
179
189
  }
180
190
  }
181
191
  // Annotate the CommonJS export names for ESM import in node:
@@ -280,8 +280,8 @@ class CRPage {
280
280
  await this._mainFrameSession._client.send("Page.enable").catch((e) => {
281
281
  });
282
282
  }
283
- async resetForReuse() {
284
- await this.rawMouse.move(-1, -1, "none", /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), true);
283
+ async resetForReuse(progress) {
284
+ await this.rawMouse.move(progress, -1, -1, "none", /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), true);
285
285
  }
286
286
  async pdf(options) {
287
287
  return this._pdf.generate(options);