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

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.
package/lib/server/dom.js CHANGED
@@ -124,7 +124,7 @@ class ElementHandle extends js.JSHandle {
124
124
  const utility = await this._frame._utilityContext();
125
125
  return await utility.evaluate(pageFunction, [await utility.injectedScript(), this, arg]);
126
126
  } catch (e) {
127
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
127
+ if ((0, import_progress.isAbortError)(e) || js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
128
128
  throw e;
129
129
  return "error:notconnected";
130
130
  }
@@ -134,7 +134,7 @@ class ElementHandle extends js.JSHandle {
134
134
  const utility = await this._frame._utilityContext();
135
135
  return await utility.evaluateHandle(pageFunction, [await utility.injectedScript(), this, arg]);
136
136
  } catch (e) {
137
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
137
+ if ((0, import_progress.isAbortError)(e) || js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
138
138
  throw e;
139
139
  return "error:notconnected";
140
140
  }
@@ -209,23 +209,23 @@ class ElementHandle extends js.JSHandle {
209
209
  async dispatchEvent(metadata, type, eventInit = {}) {
210
210
  return this._frame.dispatchEvent(metadata, ":scope", type, eventInit, { timeout: 0 }, this);
211
211
  }
212
- async _scrollRectIntoViewIfNeeded(rect) {
213
- return await this._page.delegate.scrollRectIntoViewIfNeeded(this, rect);
212
+ async _scrollRectIntoViewIfNeeded(progress, rect) {
213
+ return await progress.race(this._page.delegate.scrollRectIntoViewIfNeeded(this, rect));
214
214
  }
215
215
  async _waitAndScrollIntoViewIfNeeded(progress, waitForVisible) {
216
216
  const result = await this._retryAction(progress, "scroll into view", async () => {
217
217
  progress.log(` waiting for element to be stable`);
218
- const waitResult = await this.evaluateInUtility(async ([injected, node, { waitForVisible: waitForVisible2 }]) => {
218
+ const waitResult = await progress.race(this.evaluateInUtility(async ([injected, node, { waitForVisible: waitForVisible2 }]) => {
219
219
  return await injected.checkElementStates(node, waitForVisible2 ? ["visible", "stable"] : ["stable"]);
220
- }, { waitForVisible });
220
+ }, { waitForVisible }));
221
221
  if (waitResult)
222
222
  return waitResult;
223
- return await this._scrollRectIntoViewIfNeeded();
223
+ return await this._scrollRectIntoViewIfNeeded(progress);
224
224
  }, {});
225
225
  assertDone(throwRetargetableDOMError(result));
226
226
  }
227
227
  async scrollIntoViewIfNeeded(metadata, options) {
228
- const controller = new import_progress.ProgressController(metadata, this);
228
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
229
229
  return controller.run(
230
230
  (progress) => this._waitAndScrollIntoViewIfNeeded(
231
231
  progress,
@@ -289,13 +289,14 @@ class ElementHandle extends js.JSHandle {
289
289
  async _retryAction(progress, actionName, action, options) {
290
290
  let retry = 0;
291
291
  const waitTime = [0, 20, 100, 100, 500];
292
- while (progress.isRunning()) {
292
+ while (true) {
293
+ progress.throwIfAborted();
293
294
  if (retry) {
294
295
  progress.log(`retrying ${actionName} action${options.trial ? " (trial run)" : ""}`);
295
296
  const timeout = waitTime[Math.min(retry - 1, waitTime.length - 1)];
296
297
  if (timeout) {
297
298
  progress.log(` waiting ${timeout}ms`);
298
- const result2 = await this.evaluateInUtility(([injected, node, timeout2]) => new Promise((f) => setTimeout(f, timeout2)), timeout);
299
+ const result2 = await progress.race(this.evaluateInUtility(([injected, node, timeout2]) => new Promise((f) => setTimeout(f, timeout2)), timeout));
299
300
  if (result2 === "error:notconnected")
300
301
  return result2;
301
302
  }
@@ -332,7 +333,6 @@ class ElementHandle extends js.JSHandle {
332
333
  }
333
334
  return result;
334
335
  }
335
- return "done";
336
336
  }
337
337
  async _retryPointerAction(progress, actionName, waitForEnabled, action, options) {
338
338
  const skipActionPreChecks = actionName === "move and up";
@@ -363,51 +363,51 @@ class ElementHandle extends js.JSHandle {
363
363
  return "done";
364
364
  }, forceScrollOptions);
365
365
  }
366
- return await this._scrollRectIntoViewIfNeeded(position ? { x: position.x, y: position.y, width: 0, height: 0 } : void 0);
366
+ return await this._scrollRectIntoViewIfNeeded(progress, position ? { x: position.x, y: position.y, width: 0, height: 0 } : void 0);
367
367
  };
368
368
  if (this._frame.parentFrame()) {
369
369
  progress.throwIfAborted();
370
- await doScrollIntoView().catch(() => {
371
- });
370
+ await progress.race(doScrollIntoView().catch(() => {
371
+ }));
372
372
  }
373
373
  if (options.__testHookBeforeStable)
374
- await options.__testHookBeforeStable();
374
+ await progress.race(options.__testHookBeforeStable());
375
375
  if (!force) {
376
376
  const elementStates = waitForEnabled ? ["visible", "enabled", "stable"] : ["visible", "stable"];
377
377
  progress.log(` waiting for element to be ${waitForEnabled ? "visible, enabled and stable" : "visible and stable"}`);
378
- const result = await this.evaluateInUtility(async ([injected, node, { elementStates: elementStates2 }]) => {
378
+ const result = await progress.race(this.evaluateInUtility(async ([injected, node, { elementStates: elementStates2 }]) => {
379
379
  return await injected.checkElementStates(node, elementStates2);
380
- }, { elementStates });
380
+ }, { elementStates }));
381
381
  if (result)
382
382
  return result;
383
383
  progress.log(` element is ${waitForEnabled ? "visible, enabled and stable" : "visible and stable"}`);
384
384
  }
385
385
  if (options.__testHookAfterStable)
386
- await options.__testHookAfterStable();
386
+ await progress.race(options.__testHookAfterStable());
387
387
  progress.log(" scrolling into view if needed");
388
388
  progress.throwIfAborted();
389
- const scrolled = await doScrollIntoView();
389
+ const scrolled = await progress.race(doScrollIntoView());
390
390
  if (scrolled !== "done")
391
391
  return scrolled;
392
392
  progress.log(" done scrolling");
393
- const maybePoint = position ? await this._offsetPoint(position) : await this._clickablePoint();
393
+ const maybePoint = position ? await progress.race(this._offsetPoint(position)) : await progress.race(this._clickablePoint());
394
394
  if (typeof maybePoint === "string")
395
395
  return maybePoint;
396
396
  const point = roundPoint(maybePoint);
397
397
  progress.metadata.point = point;
398
- await this.instrumentation.onBeforeInputAction(this, progress.metadata);
398
+ await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
399
399
  let hitTargetInterceptionHandle;
400
400
  if (force) {
401
401
  progress.log(` forcing action`);
402
402
  } else {
403
403
  if (options.__testHookBeforeHitTarget)
404
- await options.__testHookBeforeHitTarget();
405
- const frameCheckResult = await this._checkFrameIsHitTarget(point);
404
+ await progress.race(options.__testHookBeforeHitTarget());
405
+ const frameCheckResult = await progress.race(this._checkFrameIsHitTarget(point));
406
406
  if (frameCheckResult === "error:notconnected" || "hitTargetDescription" in frameCheckResult)
407
407
  return frameCheckResult;
408
408
  const hitPoint = frameCheckResult.framePoint;
409
409
  const actionType = actionName === "move and up" ? "drag" : actionName === "hover" || actionName === "tap" ? actionName : "mouse";
410
- const handle = await this.evaluateHandleInUtility(([injected, node, { actionType: actionType2, hitPoint: hitPoint2, trial }]) => injected.setupHitTargetInterceptor(node, actionType2, hitPoint2, trial), { actionType, hitPoint, trial: !!options.trial });
410
+ const handle = await progress.race(this.evaluateHandleInUtility(([injected, node, { actionType: actionType2, hitPoint: hitPoint2, trial }]) => injected.setupHitTargetInterceptor(node, actionType2, hitPoint2, trial), { actionType, hitPoint, trial: !!options.trial }));
411
411
  if (handle === "error:notconnected")
412
412
  return handle;
413
413
  if (!handle._objectId) {
@@ -425,7 +425,7 @@ class ElementHandle extends js.JSHandle {
425
425
  }
426
426
  const actionResult = await this._page.frameManager.waitForSignalsCreatedBy(progress, options.waitAfter === true, async () => {
427
427
  if (options.__testHookBeforePointerAction)
428
- await options.__testHookBeforePointerAction();
428
+ await progress.race(options.__testHookBeforePointerAction());
429
429
  progress.throwIfAborted();
430
430
  let restoreModifiers;
431
431
  if (options && options.modifiers)
@@ -441,7 +441,7 @@ class ElementHandle extends js.JSHandle {
441
441
  hitTargetInterceptionHandle?.dispose();
442
442
  });
443
443
  if (options.waitAfter !== false) {
444
- const hitTargetResult = await stopHitTargetInterception;
444
+ const hitTargetResult = await progress.race(stopHitTargetInterception);
445
445
  if (hitTargetResult !== "done")
446
446
  return hitTargetResult;
447
447
  }
@@ -449,7 +449,7 @@ class ElementHandle extends js.JSHandle {
449
449
  progress.log(` ${options.trial ? "trial " : ""}${actionName} action done`);
450
450
  progress.log(" waiting for scheduled navigations to finish");
451
451
  if (options.__testHookAfterPointerAction)
452
- await options.__testHookAfterPointerAction();
452
+ await progress.race(options.__testHookAfterPointerAction());
453
453
  return "done";
454
454
  });
455
455
  if (actionResult !== "done")
@@ -457,18 +457,18 @@ class ElementHandle extends js.JSHandle {
457
457
  progress.log(" navigations have finished");
458
458
  return "done";
459
459
  }
460
- async _markAsTargetElement(metadata) {
461
- if (!metadata.id)
460
+ async _markAsTargetElement(progress) {
461
+ if (!progress.metadata.id)
462
462
  return;
463
- await this.evaluateInUtility(([injected, node, callId]) => {
463
+ await progress.race(this.evaluateInUtility(([injected, node, callId]) => {
464
464
  if (node.nodeType === 1)
465
465
  injected.markTargetElements(/* @__PURE__ */ new Set([node]), callId);
466
- }, metadata.id);
466
+ }, progress.metadata.id));
467
467
  }
468
468
  async hover(metadata, options) {
469
- const controller = new import_progress.ProgressController(metadata, this);
469
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
470
470
  return controller.run(async (progress) => {
471
- await this._markAsTargetElement(metadata);
471
+ await this._markAsTargetElement(progress);
472
472
  const result = await this._hover(progress, options);
473
473
  return assertDone(throwRetargetableDOMError(result));
474
474
  }, options.timeout);
@@ -477,9 +477,9 @@ class ElementHandle extends js.JSHandle {
477
477
  return this._retryPointerAction(progress, "hover", false, (point) => this._page.mouse._move(progress, point.x, point.y), { ...options, waitAfter: "disabled" });
478
478
  }
479
479
  async click(metadata, options) {
480
- const controller = new import_progress.ProgressController(metadata, this);
480
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
481
481
  return controller.run(async (progress) => {
482
- await this._markAsTargetElement(metadata);
482
+ await this._markAsTargetElement(progress);
483
483
  const result = await this._click(progress, { ...options, waitAfter: !options.noWaitAfter });
484
484
  return assertDone(throwRetargetableDOMError(result));
485
485
  }, options.timeout);
@@ -488,9 +488,9 @@ class ElementHandle extends js.JSHandle {
488
488
  return this._retryPointerAction(progress, "click", true, (point) => this._page.mouse._click(progress, point.x, point.y, options), options);
489
489
  }
490
490
  async dblclick(metadata, options) {
491
- const controller = new import_progress.ProgressController(metadata, this);
491
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
492
492
  return controller.run(async (progress) => {
493
- await this._markAsTargetElement(metadata);
493
+ await this._markAsTargetElement(progress);
494
494
  const result = await this._dblclick(progress, options);
495
495
  return assertDone(throwRetargetableDOMError(result));
496
496
  }, options.timeout);
@@ -499,9 +499,9 @@ class ElementHandle extends js.JSHandle {
499
499
  return this._retryPointerAction(progress, "dblclick", true, (point) => this._page.mouse._click(progress, point.x, point.y, { ...options, clickCount: 2 }), { ...options, waitAfter: "disabled" });
500
500
  }
501
501
  async tap(metadata, options) {
502
- const controller = new import_progress.ProgressController(metadata, this);
502
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
503
503
  return controller.run(async (progress) => {
504
- await this._markAsTargetElement(metadata);
504
+ await this._markAsTargetElement(progress);
505
505
  const result = await this._tap(progress, options);
506
506
  return assertDone(throwRetargetableDOMError(result));
507
507
  }, options.timeout);
@@ -510,9 +510,9 @@ class ElementHandle extends js.JSHandle {
510
510
  return this._retryPointerAction(progress, "tap", true, (point) => this._page.touchscreen._tap(progress, point.x, point.y), { ...options, waitAfter: "disabled" });
511
511
  }
512
512
  async selectOption(metadata, elements, values, options) {
513
- const controller = new import_progress.ProgressController(metadata, this);
513
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
514
514
  return controller.run(async (progress) => {
515
- await this._markAsTargetElement(metadata);
515
+ await this._markAsTargetElement(progress);
516
516
  const result = await this._selectOption(progress, elements, values, options);
517
517
  return throwRetargetableDOMError(result);
518
518
  }, options.timeout);
@@ -520,18 +520,18 @@ class ElementHandle extends js.JSHandle {
520
520
  async _selectOption(progress, elements, values, options) {
521
521
  let resultingOptions = [];
522
522
  const result = await this._retryAction(progress, "select option", async () => {
523
- await this.instrumentation.onBeforeInputAction(this, progress.metadata);
523
+ await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
524
524
  if (!options.force)
525
525
  progress.log(` waiting for element to be visible and enabled`);
526
526
  const optionsToSelect = [...elements, ...values];
527
- const result2 = await this.evaluateInUtility(async ([injected, node, { optionsToSelect: optionsToSelect2, force }]) => {
527
+ const result2 = await progress.race(this.evaluateInUtility(async ([injected, node, { optionsToSelect: optionsToSelect2, force }]) => {
528
528
  if (!force) {
529
529
  const checkResult = await injected.checkElementStates(node, ["visible", "enabled"]);
530
530
  if (checkResult)
531
531
  return checkResult;
532
532
  }
533
533
  return injected.selectOptions(node, optionsToSelect2);
534
- }, { optionsToSelect, force: options.force });
534
+ }, { optionsToSelect, force: options.force }));
535
535
  if (Array.isArray(result2)) {
536
536
  progress.log(" selected specified option(s)");
537
537
  resultingOptions = result2;
@@ -544,9 +544,9 @@ class ElementHandle extends js.JSHandle {
544
544
  return resultingOptions;
545
545
  }
546
546
  async fill(metadata, value, options) {
547
- const controller = new import_progress.ProgressController(metadata, this);
547
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
548
548
  return controller.run(async (progress) => {
549
- await this._markAsTargetElement(metadata);
549
+ await this._markAsTargetElement(progress);
550
550
  const result = await this._fill(progress, value, options);
551
551
  assertDone(throwRetargetableDOMError(result));
552
552
  }, options.timeout);
@@ -554,17 +554,17 @@ class ElementHandle extends js.JSHandle {
554
554
  async _fill(progress, value, options) {
555
555
  progress.log(` fill("${value}")`);
556
556
  return await this._retryAction(progress, "fill", async () => {
557
- await this.instrumentation.onBeforeInputAction(this, progress.metadata);
557
+ await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
558
558
  if (!options.force)
559
559
  progress.log(" waiting for element to be visible, enabled and editable");
560
- const result = await this.evaluateInUtility(async ([injected, node, { value: value2, force }]) => {
560
+ const result = await progress.race(this.evaluateInUtility(async ([injected, node, { value: value2, force }]) => {
561
561
  if (!force) {
562
562
  const checkResult = await injected.checkElementStates(node, ["visible", "enabled", "editable"]);
563
563
  if (checkResult)
564
564
  return checkResult;
565
565
  }
566
566
  return injected.fill(node, value2);
567
- }, { value, force: options.force });
567
+ }, { value, force: options.force }));
568
568
  progress.throwIfAborted();
569
569
  if (result === "needsinput") {
570
570
  if (value)
@@ -578,28 +578,28 @@ class ElementHandle extends js.JSHandle {
578
578
  }, options);
579
579
  }
580
580
  async selectText(metadata, options) {
581
- const controller = new import_progress.ProgressController(metadata, this);
581
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
582
582
  return controller.run(async (progress) => {
583
583
  const result = await this._retryAction(progress, "selectText", async () => {
584
584
  if (!options.force)
585
585
  progress.log(" waiting for element to be visible");
586
- return await this.evaluateInUtility(async ([injected, node, { force }]) => {
586
+ return await progress.race(this.evaluateInUtility(async ([injected, node, { force }]) => {
587
587
  if (!force) {
588
588
  const checkResult = await injected.checkElementStates(node, ["visible"]);
589
589
  if (checkResult)
590
590
  return checkResult;
591
591
  }
592
592
  return injected.selectText(node);
593
- }, { force: options.force });
593
+ }, { force: options.force }));
594
594
  }, options);
595
595
  assertDone(throwRetargetableDOMError(result));
596
596
  }, options.timeout);
597
597
  }
598
598
  async setInputFiles(metadata, params) {
599
- const inputFileItems = await (0, import_fileUploadUtils.prepareFilesForUpload)(this._frame, params);
600
- const controller = new import_progress.ProgressController(metadata, this);
599
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
601
600
  return controller.run(async (progress) => {
602
- await this._markAsTargetElement(metadata);
601
+ const inputFileItems = await progress.race((0, import_fileUploadUtils.prepareFilesForUpload)(this._frame, params));
602
+ await this._markAsTargetElement(progress);
603
603
  const result = await this._setInputFiles(progress, inputFileItems);
604
604
  return assertDone(throwRetargetableDOMError(result));
605
605
  }, params.timeout);
@@ -607,7 +607,7 @@ class ElementHandle extends js.JSHandle {
607
607
  async _setInputFiles(progress, items) {
608
608
  const { filePayloads, localPaths, localDirectory } = items;
609
609
  const multiple = filePayloads && filePayloads.length > 1 || localPaths && localPaths.length > 1;
610
- const result = await this.evaluateHandleInUtility(([injected, node, { multiple: multiple2, directoryUpload }]) => {
610
+ const result = await progress.race(this.evaluateHandleInUtility(([injected, node, { multiple: multiple2, directoryUpload }]) => {
611
611
  const element = injected.retarget(node, "follow-label");
612
612
  if (!element)
613
613
  return;
@@ -621,53 +621,50 @@ class ElementHandle extends js.JSHandle {
621
621
  if (!directoryUpload && inputElement.webkitdirectory)
622
622
  throw injected.createStacklessError("[webkitdirectory] input requires passing a path to a directory");
623
623
  return inputElement;
624
- }, { multiple, directoryUpload: !!localDirectory });
624
+ }, { multiple, directoryUpload: !!localDirectory }));
625
625
  if (result === "error:notconnected" || !result.asElement())
626
626
  return "error:notconnected";
627
627
  const retargeted = result.asElement();
628
- await this.instrumentation.onBeforeInputAction(this, progress.metadata);
629
- progress.throwIfAborted();
628
+ await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
630
629
  if (localPaths || localDirectory) {
631
630
  const localPathsOrDirectory = localDirectory ? [localDirectory] : localPaths;
632
- await Promise.all(localPathsOrDirectory.map((localPath) => import_fs.default.promises.access(localPath, import_fs.default.constants.F_OK)));
631
+ await progress.race(Promise.all(localPathsOrDirectory.map((localPath) => import_fs.default.promises.access(localPath, import_fs.default.constants.F_OK))));
633
632
  const waitForInputEvent = localDirectory ? this.evaluate((node) => new Promise((fulfill) => {
634
633
  node.addEventListener("input", fulfill, { once: true });
635
634
  })).catch(() => {
636
635
  }) : Promise.resolve();
637
- await this._page.delegate.setInputFilePaths(retargeted, localPathsOrDirectory);
638
- await waitForInputEvent;
636
+ await progress.race(this._page.delegate.setInputFilePaths(retargeted, localPathsOrDirectory));
637
+ await progress.race(waitForInputEvent);
639
638
  } else {
640
- await retargeted.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), filePayloads);
639
+ await progress.race(retargeted.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), filePayloads));
641
640
  }
642
641
  return "done";
643
642
  }
644
643
  async focus(metadata) {
645
- const controller = new import_progress.ProgressController(metadata, this);
644
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
646
645
  await controller.run(async (progress) => {
647
- await this._markAsTargetElement(metadata);
646
+ await this._markAsTargetElement(progress);
648
647
  const result = await this._focus(progress);
649
648
  return assertDone(throwRetargetableDOMError(result));
650
649
  }, 0);
651
650
  }
652
651
  async _focus(progress, resetSelectionIfNotFocused) {
653
- progress.throwIfAborted();
654
- return await this.evaluateInUtility(([injected, node, resetSelectionIfNotFocused2]) => injected.focusNode(node, resetSelectionIfNotFocused2), resetSelectionIfNotFocused);
652
+ return await progress.race(this.evaluateInUtility(([injected, node, resetSelectionIfNotFocused2]) => injected.focusNode(node, resetSelectionIfNotFocused2), resetSelectionIfNotFocused));
655
653
  }
656
654
  async _blur(progress) {
657
- progress.throwIfAborted();
658
- return await this.evaluateInUtility(([injected, node]) => injected.blurNode(node), {});
655
+ return await progress.race(this.evaluateInUtility(([injected, node]) => injected.blurNode(node), {}));
659
656
  }
660
657
  async type(metadata, text, options) {
661
- const controller = new import_progress.ProgressController(metadata, this);
658
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
662
659
  return controller.run(async (progress) => {
663
- await this._markAsTargetElement(metadata);
660
+ await this._markAsTargetElement(progress);
664
661
  const result = await this._type(progress, text, options);
665
662
  return assertDone(throwRetargetableDOMError(result));
666
663
  }, options.timeout);
667
664
  }
668
665
  async _type(progress, text, options) {
669
666
  progress.log(`elementHandle.type("${text}")`);
670
- await this.instrumentation.onBeforeInputAction(this, progress.metadata);
667
+ await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
671
668
  const result = await this._focus(
672
669
  progress,
673
670
  true
@@ -675,21 +672,20 @@ class ElementHandle extends js.JSHandle {
675
672
  );
676
673
  if (result !== "done")
677
674
  return result;
678
- progress.throwIfAborted();
679
675
  await this._page.keyboard._type(progress, text, options);
680
676
  return "done";
681
677
  }
682
678
  async press(metadata, key, options) {
683
- const controller = new import_progress.ProgressController(metadata, this);
679
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
684
680
  return controller.run(async (progress) => {
685
- await this._markAsTargetElement(metadata);
681
+ await this._markAsTargetElement(progress);
686
682
  const result = await this._press(progress, key, options);
687
683
  return assertDone(throwRetargetableDOMError(result));
688
684
  }, options.timeout);
689
685
  }
690
686
  async _press(progress, key, options) {
691
687
  progress.log(`elementHandle.press("${key}")`);
692
- await this.instrumentation.onBeforeInputAction(this, progress.metadata);
688
+ await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
693
689
  return this._page.frameManager.waitForSignalsCreatedBy(progress, !options.noWaitAfter, async () => {
694
690
  const result = await this._focus(
695
691
  progress,
@@ -698,20 +694,19 @@ class ElementHandle extends js.JSHandle {
698
694
  );
699
695
  if (result !== "done")
700
696
  return result;
701
- progress.throwIfAborted();
702
697
  await this._page.keyboard._press(progress, key, options);
703
698
  return "done";
704
699
  });
705
700
  }
706
701
  async check(metadata, options) {
707
- const controller = new import_progress.ProgressController(metadata, this);
702
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
708
703
  return controller.run(async (progress) => {
709
704
  const result = await this._setChecked(progress, true, options);
710
705
  return assertDone(throwRetargetableDOMError(result));
711
706
  }, options.timeout);
712
707
  }
713
708
  async uncheck(metadata, options) {
714
- const controller = new import_progress.ProgressController(metadata, this);
709
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
715
710
  return controller.run(async (progress) => {
716
711
  const result = await this._setChecked(progress, false, options);
717
712
  return assertDone(throwRetargetableDOMError(result));
@@ -719,12 +714,12 @@ class ElementHandle extends js.JSHandle {
719
714
  }
720
715
  async _setChecked(progress, state, options) {
721
716
  const isChecked = async () => {
722
- const result2 = await this.evaluateInUtility(([injected, node]) => injected.elementState(node, "checked"), {});
717
+ const result2 = await progress.race(this.evaluateInUtility(([injected, node]) => injected.elementState(node, "checked"), {}));
723
718
  if (result2 === "error:notconnected" || result2.received === "error:notconnected")
724
719
  throwElementIsNotAttached();
725
720
  return result2.matches;
726
721
  };
727
- await this._markAsTargetElement(progress.metadata);
722
+ await this._markAsTargetElement(progress);
728
723
  if (await isChecked() === state)
729
724
  return "done";
730
725
  const result = await this._click(progress, { ...options, waitAfter: "disabled" });
@@ -780,13 +775,13 @@ class ElementHandle extends js.JSHandle {
780
775
  return this._frame.isChecked(metadata, ":scope", { timeout: 0 }, this);
781
776
  }
782
777
  async waitForElementState(metadata, state, options) {
783
- const controller = new import_progress.ProgressController(metadata, this);
778
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
784
779
  return controller.run(async (progress) => {
785
780
  const actionName = `wait for ${state}`;
786
781
  const result = await this._retryAction(progress, actionName, async () => {
787
- return await this.evaluateInUtility(async ([injected, node, state2]) => {
782
+ return await progress.race(this.evaluateInUtility(async ([injected, node, state2]) => {
788
783
  return await injected.checkElementStates(node, [state2]) || "done";
789
- }, state);
784
+ }, state));
790
785
  }, {});
791
786
  assertDone(throwRetargetableDOMError(result));
792
787
  }, options.timeout);
@@ -63,7 +63,7 @@ class RawKeyboardImpl {
63
63
  if (text === "\r")
64
64
  text = "";
65
65
  const { code, key, location } = description;
66
- await this._client.send("Page.dispatchKeyEvent", {
66
+ await progress.race(this._client.send("Page.dispatchKeyEvent", {
67
67
  type: "keydown",
68
68
  keyCode: description.keyCodeWithoutLocation,
69
69
  code,
@@ -71,24 +71,21 @@ class RawKeyboardImpl {
71
71
  repeat: autoRepeat,
72
72
  location,
73
73
  text
74
- });
75
- progress.throwIfAborted();
74
+ }));
76
75
  }
77
76
  async keyup(progress, modifiers, keyName, description) {
78
77
  const { code, key, location } = description;
79
- await this._client.send("Page.dispatchKeyEvent", {
78
+ await progress.race(this._client.send("Page.dispatchKeyEvent", {
80
79
  type: "keyup",
81
80
  key,
82
81
  keyCode: description.keyCodeWithoutLocation,
83
82
  code,
84
83
  location,
85
84
  repeat: false
86
- });
87
- progress.throwIfAborted();
85
+ }));
88
86
  }
89
87
  async sendText(progress, text) {
90
- await this._client.send("Page.insertText", { text });
91
- progress.throwIfAborted();
88
+ await progress.race(this._client.send("Page.insertText", { text }));
92
89
  }
93
90
  }
94
91
  class RawMouseImpl {
@@ -96,18 +93,17 @@ class RawMouseImpl {
96
93
  this._client = client;
97
94
  }
98
95
  async move(progress, x, y, button, buttons, modifiers, forClick) {
99
- await this._client.send("Page.dispatchMouseEvent", {
96
+ await progress.race(this._client.send("Page.dispatchMouseEvent", {
100
97
  type: "mousemove",
101
98
  button: 0,
102
99
  buttons: toButtonsMask(buttons),
103
100
  x: Math.floor(x),
104
101
  y: Math.floor(y),
105
102
  modifiers: toModifiersMask(modifiers)
106
- });
107
- progress.throwIfAborted();
103
+ }));
108
104
  }
109
105
  async down(progress, x, y, button, buttons, modifiers, clickCount) {
110
- await this._client.send("Page.dispatchMouseEvent", {
106
+ await progress.race(this._client.send("Page.dispatchMouseEvent", {
111
107
  type: "mousedown",
112
108
  button: toButtonNumber(button),
113
109
  buttons: toButtonsMask(buttons),
@@ -115,11 +111,10 @@ class RawMouseImpl {
115
111
  y: Math.floor(y),
116
112
  modifiers: toModifiersMask(modifiers),
117
113
  clickCount
118
- });
119
- progress.throwIfAborted();
114
+ }));
120
115
  }
121
116
  async up(progress, x, y, button, buttons, modifiers, clickCount) {
122
- await this._client.send("Page.dispatchMouseEvent", {
117
+ await progress.race(this._client.send("Page.dispatchMouseEvent", {
123
118
  type: "mouseup",
124
119
  button: toButtonNumber(button),
125
120
  buttons: toButtonsMask(buttons),
@@ -127,20 +122,18 @@ class RawMouseImpl {
127
122
  y: Math.floor(y),
128
123
  modifiers: toModifiersMask(modifiers),
129
124
  clickCount
130
- });
131
- progress.throwIfAborted();
125
+ }));
132
126
  }
133
127
  async wheel(progress, x, y, buttons, modifiers, deltaX, deltaY) {
134
128
  await this._page.mainFrame().evaluateExpression(`new Promise(requestAnimationFrame)`, { world: "utility" });
135
- await this._client.send("Page.dispatchWheelEvent", {
129
+ await progress.race(this._client.send("Page.dispatchWheelEvent", {
136
130
  deltaX,
137
131
  deltaY,
138
132
  x: Math.floor(x),
139
133
  y: Math.floor(y),
140
134
  deltaZ: 0,
141
135
  modifiers: toModifiersMask(modifiers)
142
- });
143
- progress.throwIfAborted();
136
+ }));
144
137
  }
145
138
  setPage(page) {
146
139
  this._page = page;
@@ -151,12 +144,11 @@ class RawTouchscreenImpl {
151
144
  this._client = client;
152
145
  }
153
146
  async tap(progress, x, y, modifiers) {
154
- await this._client.send("Page.dispatchTapEvent", {
147
+ await progress.race(this._client.send("Page.dispatchTapEvent", {
155
148
  x,
156
149
  y,
157
150
  modifiers: toModifiersMask(modifiers)
158
- });
159
- progress.throwIfAborted();
151
+ }));
160
152
  }
161
153
  }
162
154
  // Annotate the CommonJS export names for ESM import in node: