playwright-core 1.54.0-alpha-2025-06-16 → 1.54.0-alpha-2025-06-18

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.
@@ -1888,7 +1888,7 @@ import_validatorPrimitives.scheme.FrameWaitForSelectorResult = (0, import_valida
1888
1888
  element: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tChannel)(["ElementHandle"]))
1889
1889
  });
1890
1890
  import_validatorPrimitives.scheme.FrameExpectParams = (0, import_validatorPrimitives.tObject)({
1891
- selector: import_validatorPrimitives.tString,
1891
+ selector: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
1892
1892
  expression: import_validatorPrimitives.tString,
1893
1893
  expressionArg: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tAny),
1894
1894
  expectedText: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("ExpectedTextValue"))),
@@ -40,6 +40,16 @@ class PlaywrightServer {
40
40
  const controllerSemaphore = new import_semaphore.Semaphore(1);
41
41
  const reuseBrowserSemaphore = new import_semaphore.Semaphore(1);
42
42
  this._wsServer = new import_wsServer.WSServer({
43
+ onRequest: (request, response) => {
44
+ if (request.method === "GET" && request.url === "/json") {
45
+ response.setHeader("Content-Type", "application/json");
46
+ response.end(JSON.stringify({
47
+ wsEndpointPath: this._options.path
48
+ }));
49
+ return;
50
+ }
51
+ response.end("Running");
52
+ },
43
53
  onUpgrade: (request, socket) => {
44
54
  const uaError = userAgentVersionMatchesErrorMessage(request.headers["user-agent"] || "");
45
55
  if (uaError)
@@ -65,7 +65,7 @@ class RawKeyboardImpl {
65
65
  await this._performActions(progress, actions);
66
66
  }
67
67
  async _performActions(progress, actions) {
68
- await this._session.send("input.performActions", {
68
+ await progress.race(this._session.send("input.performActions", {
69
69
  context: this._session.sessionId,
70
70
  actions: [
71
71
  {
@@ -74,8 +74,7 @@ class RawKeyboardImpl {
74
74
  actions
75
75
  }
76
76
  ]
77
- });
78
- progress.throwIfAborted();
77
+ }));
79
78
  }
80
79
  }
81
80
  class RawMouseImpl {
@@ -94,7 +93,7 @@ class RawMouseImpl {
94
93
  async wheel(progress, x, y, buttons, modifiers, deltaX, deltaY) {
95
94
  x = Math.floor(x);
96
95
  y = Math.floor(y);
97
- await this._session.send("input.performActions", {
96
+ await progress.race(this._session.send("input.performActions", {
98
97
  context: this._session.sessionId,
99
98
  actions: [
100
99
  {
@@ -103,11 +102,10 @@ class RawMouseImpl {
103
102
  actions: [{ type: "scroll", x, y, deltaX, deltaY }]
104
103
  }
105
104
  ]
106
- });
107
- progress.throwIfAborted();
105
+ }));
108
106
  }
109
107
  async _performActions(progress, actions) {
110
- await this._session.send("input.performActions", {
108
+ await progress.race(this._session.send("input.performActions", {
111
109
  context: this._session.sessionId,
112
110
  actions: [
113
111
  {
@@ -119,8 +117,7 @@ class RawMouseImpl {
119
117
  actions
120
118
  }
121
119
  ]
122
- });
123
- progress.throwIfAborted();
120
+ }));
124
121
  }
125
122
  }
126
123
  class RawTouchscreenImpl {
@@ -143,8 +143,7 @@ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { co
143
143
  return true;
144
144
  }
145
145
  async stopPendingOperations(reason) {
146
- for (const controller of this._activeProgressControllers)
147
- controller.abort(new Error(reason));
146
+ await Promise.all(Array.from(this._activeProgressControllers).map((controller) => controller.abort(reason)));
148
147
  await new Promise((f) => setTimeout(f, 0));
149
148
  }
150
149
  static reusableContextHash(params) {
@@ -47,14 +47,13 @@ class DragManager {
47
47
  async interceptDragCausedByMove(progress, x, y, button, buttons, modifiers, moveCallback) {
48
48
  this._lastPosition = { x, y };
49
49
  if (this._dragState) {
50
- await this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
50
+ await progress.race(this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
51
51
  type: "dragOver",
52
52
  x,
53
53
  y,
54
54
  data: this._dragState,
55
55
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers)
56
- });
57
- progress.throwIfAborted();
56
+ }));
58
57
  return;
59
58
  }
60
59
  if (button !== "left")
@@ -96,17 +95,15 @@ class DragManager {
96
95
  }))).some((x2) => x2);
97
96
  this._dragState = expectingDrag ? (await dragInterceptedPromise).data : null;
98
97
  client.off("Input.dragIntercepted", onDragIntercepted);
99
- await client.send("Input.setInterceptDrags", { enabled: false });
100
- progress.throwIfAborted();
98
+ await progress.race(client.send("Input.setInterceptDrags", { enabled: false }));
101
99
  if (this._dragState) {
102
- await this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
100
+ await progress.race(this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
103
101
  type: "dragEnter",
104
102
  x,
105
103
  y,
106
104
  data: this._dragState,
107
105
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers)
108
- });
109
- progress.throwIfAborted();
106
+ }));
110
107
  }
111
108
  }
112
109
  isDragging() {
@@ -114,15 +111,14 @@ class DragManager {
114
111
  }
115
112
  async drop(progress, x, y, modifiers) {
116
113
  (0, import_utils.assert)(this._dragState, "missing drag state");
117
- await this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
114
+ await progress.race(this._crPage._mainFrameSession._client.send("Input.dispatchDragEvent", {
118
115
  type: "drop",
119
116
  x,
120
117
  y,
121
118
  data: this._dragState,
122
119
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers)
123
- });
120
+ }));
124
121
  this._dragState = null;
125
- progress.throwIfAborted();
126
122
  }
127
123
  }
128
124
  // Annotate the CommonJS export names for ESM import in node:
@@ -61,11 +61,10 @@ class RawKeyboardImpl {
61
61
  }
62
62
  async keydown(progress, modifiers, keyName, description, autoRepeat) {
63
63
  const { code, key, location, text } = description;
64
- if (code === "Escape" && await this._dragManger.cancelDrag())
64
+ if (code === "Escape" && await progress.race(this._dragManger.cancelDrag()))
65
65
  return;
66
- progress.throwIfAborted();
67
66
  const commands = this._commandsForCode(code, modifiers);
68
- await this._client.send("Input.dispatchKeyEvent", {
67
+ await progress.race(this._client.send("Input.dispatchKeyEvent", {
69
68
  type: text ? "keyDown" : "rawKeyDown",
70
69
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
71
70
  windowsVirtualKeyCode: description.keyCodeWithoutLocation,
@@ -77,24 +76,21 @@ class RawKeyboardImpl {
77
76
  autoRepeat,
78
77
  location,
79
78
  isKeypad: location === input.keypadLocation
80
- });
81
- progress.throwIfAborted();
79
+ }));
82
80
  }
83
81
  async keyup(progress, modifiers, keyName, description) {
84
82
  const { code, key, location } = description;
85
- await this._client.send("Input.dispatchKeyEvent", {
83
+ await progress.race(this._client.send("Input.dispatchKeyEvent", {
86
84
  type: "keyUp",
87
85
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
88
86
  key,
89
87
  windowsVirtualKeyCode: description.keyCodeWithoutLocation,
90
88
  code,
91
89
  location
92
- });
93
- progress.throwIfAborted();
90
+ }));
94
91
  }
95
92
  async sendText(progress, text) {
96
- await this._client.send("Input.insertText", { text });
97
- progress.throwIfAborted();
93
+ await progress.race(this._client.send("Input.insertText", { text }));
98
94
  }
99
95
  }
100
96
  class RawMouseImpl {
@@ -105,7 +101,7 @@ class RawMouseImpl {
105
101
  }
106
102
  async move(progress, x, y, button, buttons, modifiers, forClick) {
107
103
  const actualMove = async () => {
108
- await this._client.send("Input.dispatchMouseEvent", {
104
+ await progress.race(this._client.send("Input.dispatchMouseEvent", {
109
105
  type: "mouseMoved",
110
106
  button,
111
107
  buttons: (0, import_crProtocolHelper.toButtonsMask)(buttons),
@@ -113,11 +109,10 @@ class RawMouseImpl {
113
109
  y,
114
110
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
115
111
  force: buttons.size > 0 ? 0.5 : 0
116
- });
112
+ }));
117
113
  };
118
114
  if (forClick) {
119
115
  await actualMove();
120
- progress.throwIfAborted();
121
116
  return;
122
117
  }
123
118
  await this._dragManager.interceptDragCausedByMove(progress, x, y, button, buttons, modifiers, actualMove);
@@ -125,7 +120,7 @@ class RawMouseImpl {
125
120
  async down(progress, x, y, button, buttons, modifiers, clickCount) {
126
121
  if (this._dragManager.isDragging())
127
122
  return;
128
- await this._client.send("Input.dispatchMouseEvent", {
123
+ await progress.race(this._client.send("Input.dispatchMouseEvent", {
129
124
  type: "mousePressed",
130
125
  button,
131
126
  buttons: (0, import_crProtocolHelper.toButtonsMask)(buttons),
@@ -134,15 +129,14 @@ class RawMouseImpl {
134
129
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
135
130
  clickCount,
136
131
  force: buttons.size > 0 ? 0.5 : 0
137
- });
138
- progress.throwIfAborted();
132
+ }));
139
133
  }
140
134
  async up(progress, x, y, button, buttons, modifiers, clickCount) {
141
135
  if (this._dragManager.isDragging()) {
142
136
  await this._dragManager.drop(progress, x, y, modifiers);
143
137
  return;
144
138
  }
145
- await this._client.send("Input.dispatchMouseEvent", {
139
+ await progress.race(this._client.send("Input.dispatchMouseEvent", {
146
140
  type: "mouseReleased",
147
141
  button,
148
142
  buttons: (0, import_crProtocolHelper.toButtonsMask)(buttons),
@@ -150,19 +144,17 @@ class RawMouseImpl {
150
144
  y,
151
145
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
152
146
  clickCount
153
- });
154
- progress.throwIfAborted();
147
+ }));
155
148
  }
156
149
  async wheel(progress, x, y, buttons, modifiers, deltaX, deltaY) {
157
- await this._client.send("Input.dispatchMouseEvent", {
150
+ await progress.race(this._client.send("Input.dispatchMouseEvent", {
158
151
  type: "mouseWheel",
159
152
  x,
160
153
  y,
161
154
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
162
155
  deltaX,
163
156
  deltaY
164
- });
165
- progress.throwIfAborted();
157
+ }));
166
158
  }
167
159
  }
168
160
  class RawTouchscreenImpl {
@@ -170,7 +162,7 @@ class RawTouchscreenImpl {
170
162
  this._client = client;
171
163
  }
172
164
  async tap(progress, x, y, modifiers) {
173
- await Promise.all([
165
+ await progress.race(Promise.all([
174
166
  this._client.send("Input.dispatchTouchEvent", {
175
167
  type: "touchStart",
176
168
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
@@ -184,8 +176,7 @@ class RawTouchscreenImpl {
184
176
  modifiers: (0, import_crProtocolHelper.toModifiersMask)(modifiers),
185
177
  touchPoints: []
186
178
  })
187
- ]);
188
- progress.throwIfAborted();
179
+ ]));
189
180
  }
190
181
  }
191
182
  // Annotate the CommonJS export names for ESM import in node: