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.
@@ -119,10 +119,9 @@ class FrameManager {
119
119
  return action();
120
120
  const barrier = new SignalBarrier(progress);
121
121
  this._signalBarriers.add(barrier);
122
- if (progress)
123
- progress.cleanupWhenAborted(() => this._signalBarriers.delete(barrier));
122
+ progress.cleanupWhenAborted(() => this._signalBarriers.delete(barrier));
124
123
  const result = await action();
125
- await this._page.delegate.inputActionEpilogue();
124
+ await progress.race(this._page.delegate.inputActionEpilogue());
126
125
  await barrier.waitFor();
127
126
  this._signalBarriers.delete(barrier);
128
127
  await new Promise((0, import_utils.makeWaitForNextTask)());
@@ -604,15 +603,15 @@ class Frame extends import_instrumentation.SdkObject {
604
603
  return this.selectors.query(selector, options);
605
604
  }
606
605
  async waitForSelector(metadata, selector, options, scope) {
607
- const controller = new import_progress.ProgressController(metadata, this);
608
- if (options.visibility)
609
- throw new Error("options.visibility is not supported, did you mean options.state?");
610
- if (options.waitFor && options.waitFor !== "visible")
611
- throw new Error("options.waitFor is not supported, did you mean options.state?");
612
- const { state = "visible" } = options;
613
- if (!["attached", "detached", "visible", "hidden"].includes(state))
614
- throw new Error(`state: expected one of (attached|detached|visible|hidden)`);
606
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
615
607
  return controller.run(async (progress) => {
608
+ if (options.visibility)
609
+ throw new Error("options.visibility is not supported, did you mean options.state?");
610
+ if (options.waitFor && options.waitFor !== "visible")
611
+ throw new Error("options.waitFor is not supported, did you mean options.state?");
612
+ const { state = "visible" } = options;
613
+ if (!["attached", "detached", "visible", "hidden"].includes(state))
614
+ throw new Error(`state: expected one of (attached|detached|visible|hidden)`);
616
615
  progress.log(`waiting for ${this._asLocator(selector)}${state === "attached" ? "" : " to be " + state}`);
617
616
  return await this.waitForSelectorInternal(progress, selector, true, options, scope);
618
617
  }, options.timeout);
@@ -622,14 +621,13 @@ class Frame extends import_instrumentation.SdkObject {
622
621
  const promise = this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling) => {
623
622
  if (performActionPreChecks)
624
623
  await this._page.performActionPreChecks(progress);
625
- const resolved = await this.selectors.resolveInjectedForSelector(selector, options, scope);
626
- progress.throwIfAborted();
624
+ const resolved = await progress.race(this.selectors.resolveInjectedForSelector(selector, options, scope));
627
625
  if (!resolved) {
628
626
  if (state === "hidden" || state === "detached")
629
627
  return null;
630
628
  return continuePolling;
631
629
  }
632
- const result = await resolved.injected.evaluateHandle((injected, { info, root }) => {
630
+ const result = await progress.raceWithCleanup(resolved.injected.evaluateHandle((injected, { info, root }) => {
633
631
  if (root && !root.isConnected)
634
632
  throw injected.createStacklessError("Element is not attached to the DOM");
635
633
  const elements = injected.querySelectorAll(info.parsed, root || document);
@@ -644,8 +642,8 @@ class Frame extends import_instrumentation.SdkObject {
644
642
  log2 = ` locator resolved to ${visible2 ? "visible" : "hidden"} ${injected.previewNode(element2)}`;
645
643
  }
646
644
  return { log: log2, element: element2, visible: visible2, attached: !!element2 };
647
- }, { info: resolved.info, root: resolved.frame === this ? scope : void 0 });
648
- const { log, visible, attached } = await result.evaluate((r) => ({ log: r.log, visible: r.visible, attached: r.attached }));
645
+ }, { info: resolved.info, root: resolved.frame === this ? scope : void 0 }), (handle) => handle.dispose());
646
+ const { log, visible, attached } = await progress.race(result.evaluate((r) => ({ log: r.log, visible: r.visible, attached: r.attached })));
649
647
  if (log)
650
648
  progress.log(log);
651
649
  const success = { attached, detached: !attached, visible, hidden: !visible }[state];
@@ -657,14 +655,15 @@ class Frame extends import_instrumentation.SdkObject {
657
655
  result.dispose();
658
656
  return null;
659
657
  }
660
- const element = state === "attached" || state === "visible" ? await result.evaluateHandle((r) => r.element) : null;
658
+ const element = state === "attached" || state === "visible" ? await progress.race(result.evaluateHandle((r) => r.element)) : null;
661
659
  result.dispose();
662
660
  if (!element)
663
661
  return null;
664
662
  if (options.__testHookBeforeAdoptNode)
665
- await options.__testHookBeforeAdoptNode();
663
+ await progress.race(options.__testHookBeforeAdoptNode());
666
664
  try {
667
- return await element._adoptTo(await resolved.frame._mainContext());
665
+ const mainContext = await progress.race(resolved.frame._mainContext());
666
+ return await progress.race(element._adoptTo(mainContext));
668
667
  } catch (e) {
669
668
  return continuePolling;
670
669
  }
@@ -715,7 +714,7 @@ class Frame extends import_instrumentation.SdkObject {
715
714
  return retVal;
716
715
  });
717
716
  } catch (e) {
718
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
717
+ if ((0, import_progress.isAbortError)(e) || js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
719
718
  throw e;
720
719
  throw new Error(`Unable to retrieve content because the page is navigating and changing the content.`);
721
720
  }
@@ -870,16 +869,15 @@ class Frame extends import_instrumentation.SdkObject {
870
869
  const continuePolling = Symbol("continuePolling");
871
870
  timeouts = [0, ...timeouts];
872
871
  let timeoutIndex = 0;
873
- while (progress.isRunning()) {
872
+ while (true) {
874
873
  const timeout = timeouts[Math.min(timeoutIndex++, timeouts.length - 1)];
875
874
  if (timeout) {
876
875
  const actionPromise = new Promise((f) => setTimeout(f, timeout));
877
- await import_utils.LongStandingScope.raceMultiple([
876
+ await progress.race(import_utils.LongStandingScope.raceMultiple([
878
877
  this._page.openScope,
879
878
  this._detachedScope
880
- ], actionPromise);
879
+ ], actionPromise));
881
880
  }
882
- progress.throwIfAborted();
883
881
  try {
884
882
  const result = await action(continuePolling);
885
883
  if (result === continuePolling)
@@ -891,10 +889,10 @@ class Frame extends import_instrumentation.SdkObject {
891
889
  continue;
892
890
  }
893
891
  }
894
- progress.throwIfAborted();
895
- return void 0;
896
892
  }
897
893
  _isErrorThatCannotBeRetried(e) {
894
+ if ((0, import_progress.isAbortError)(e))
895
+ return true;
898
896
  if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
899
897
  return true;
900
898
  if (dom.isNonRecoverableDOMError(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
@@ -908,11 +906,10 @@ class Frame extends import_instrumentation.SdkObject {
908
906
  return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling) => {
909
907
  if (performActionPreChecks)
910
908
  await this._page.performActionPreChecks(progress);
911
- const resolved = await this.selectors.resolveInjectedForSelector(selector, { strict });
912
- progress.throwIfAborted();
909
+ const resolved = await progress.race(this.selectors.resolveInjectedForSelector(selector, { strict }));
913
910
  if (!resolved)
914
911
  return continuePolling;
915
- const result = await resolved.injected.evaluateHandle((injected, { info, callId }) => {
912
+ const result = await progress.raceWithCleanup(resolved.injected.evaluateHandle((injected, { info, callId }) => {
916
913
  const elements = injected.querySelectorAll(info.parsed, document);
917
914
  if (callId)
918
915
  injected.markTargetElements(new Set(elements), callId);
@@ -926,15 +923,15 @@ class Frame extends import_instrumentation.SdkObject {
926
923
  log2 = ` locator resolved to ${injected.previewNode(element2)}`;
927
924
  }
928
925
  return { log: log2, success: !!element2, element: element2 };
929
- }, { info: resolved.info, callId: progress.metadata.id });
930
- const { log, success } = await result.evaluate((r) => ({ log: r.log, success: r.success }));
926
+ }, { info: resolved.info, callId: progress.metadata.id }), (handle) => handle.dispose());
927
+ const { log, success } = await progress.race(result.evaluate((r) => ({ log: r.log, success: r.success })));
931
928
  if (log)
932
929
  progress.log(log);
933
930
  if (!success) {
934
931
  result.dispose();
935
932
  return continuePolling;
936
933
  }
937
- const element = await result.evaluateHandle((r) => r.element);
934
+ const element = await progress.race(result.evaluateHandle((r) => r.element));
938
935
  result.dispose();
939
936
  try {
940
937
  const result2 = await action(element);
@@ -955,19 +952,19 @@ class Frame extends import_instrumentation.SdkObject {
955
952
  });
956
953
  }
957
954
  async click(metadata, selector, options) {
958
- const controller = new import_progress.ProgressController(metadata, this);
955
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
959
956
  return controller.run(async (progress) => {
960
957
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._click(progress, { ...options, waitAfter: !options.noWaitAfter })));
961
958
  }, options.timeout);
962
959
  }
963
960
  async dblclick(metadata, selector, options) {
964
- const controller = new import_progress.ProgressController(metadata, this);
961
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
965
962
  return controller.run(async (progress) => {
966
963
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._dblclick(progress, options)));
967
964
  }, options.timeout);
968
965
  }
969
966
  async dragAndDrop(metadata, source, target, options) {
970
- const controller = new import_progress.ProgressController(metadata, this);
967
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
971
968
  await controller.run(async (progress) => {
972
969
  dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, !options.force, async (handle) => {
973
970
  return handle._retryPointerAction(progress, "move and down", false, async (point) => {
@@ -976,8 +973,7 @@ class Frame extends import_instrumentation.SdkObject {
976
973
  }, {
977
974
  ...options,
978
975
  waitAfter: "disabled",
979
- position: options.sourcePosition,
980
- timeout: progress.timeUntilDeadline()
976
+ position: options.sourcePosition
981
977
  });
982
978
  }));
983
979
  dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, false, async (handle) => {
@@ -987,34 +983,33 @@ class Frame extends import_instrumentation.SdkObject {
987
983
  }, {
988
984
  ...options,
989
985
  waitAfter: "disabled",
990
- position: options.targetPosition,
991
- timeout: progress.timeUntilDeadline()
986
+ position: options.targetPosition
992
987
  });
993
988
  }));
994
989
  }, options.timeout);
995
990
  }
996
991
  async tap(metadata, selector, options) {
997
- if (!this._page.browserContext._options.hasTouch)
998
- throw new Error("The page does not support tap. Use hasTouch context option to enable touch support.");
999
- const controller = new import_progress.ProgressController(metadata, this);
992
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1000
993
  return controller.run(async (progress) => {
994
+ if (!this._page.browserContext._options.hasTouch)
995
+ throw new Error("The page does not support tap. Use hasTouch context option to enable touch support.");
1001
996
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._tap(progress, options)));
1002
997
  }, options.timeout);
1003
998
  }
1004
999
  async fill(metadata, selector, value, options) {
1005
- const controller = new import_progress.ProgressController(metadata, this);
1000
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1006
1001
  return controller.run(async (progress) => {
1007
1002
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._fill(progress, value, options)));
1008
1003
  }, options.timeout);
1009
1004
  }
1010
1005
  async focus(metadata, selector, options) {
1011
- const controller = new import_progress.ProgressController(metadata, this);
1006
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1012
1007
  await controller.run(async (progress) => {
1013
1008
  dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._focus(progress)));
1014
1009
  }, options.timeout);
1015
1010
  }
1016
1011
  async blur(metadata, selector, options) {
1017
- const controller = new import_progress.ProgressController(metadata, this);
1012
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1018
1013
  await controller.run(async (progress) => {
1019
1014
  dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._blur(progress)));
1020
1015
  }, options.timeout);
@@ -1069,24 +1064,24 @@ class Frame extends import_instrumentation.SdkObject {
1069
1064
  return result.matches;
1070
1065
  }
1071
1066
  async isVisible(metadata, selector, options = {}, scope) {
1072
- const controller = new import_progress.ProgressController(metadata, this);
1067
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1073
1068
  return controller.run(async (progress) => {
1074
1069
  progress.log(` checking visibility of ${this._asLocator(selector)}`);
1075
- return await this.isVisibleInternal(selector, options, scope);
1070
+ return await this.isVisibleInternal(progress, selector, options, scope);
1076
1071
  }, 0);
1077
1072
  }
1078
- async isVisibleInternal(selector, options = {}, scope) {
1073
+ async isVisibleInternal(progress, selector, options = {}, scope) {
1079
1074
  try {
1080
- const resolved = await this.selectors.resolveInjectedForSelector(selector, options, scope);
1075
+ const resolved = await progress.race(this.selectors.resolveInjectedForSelector(selector, options, scope));
1081
1076
  if (!resolved)
1082
1077
  return false;
1083
- return await resolved.injected.evaluate((injected, { info, root }) => {
1078
+ return await progress.race(resolved.injected.evaluate((injected, { info, root }) => {
1084
1079
  const element = injected.querySelector(info.parsed, root || document, info.strict);
1085
1080
  const state = element ? injected.elementState(element, "visible") : { matches: false, received: "error:notconnected" };
1086
1081
  return state.matches;
1087
- }, { info: resolved.info, root: resolved.frame === this ? scope : void 0 });
1082
+ }, { info: resolved.info, root: resolved.frame === this ? scope : void 0 }));
1088
1083
  } catch (e) {
1089
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e) || (0, import_protocolError.isSessionClosedError)(e))
1084
+ if ((0, import_progress.isAbortError)(e) || js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e) || (0, import_protocolError.isSessionClosedError)(e))
1090
1085
  throw e;
1091
1086
  return false;
1092
1087
  }
@@ -1107,53 +1102,51 @@ class Frame extends import_instrumentation.SdkObject {
1107
1102
  return this._elementState(metadata, selector, "checked", options, scope);
1108
1103
  }
1109
1104
  async hover(metadata, selector, options) {
1110
- const controller = new import_progress.ProgressController(metadata, this);
1105
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1111
1106
  return controller.run(async (progress) => {
1112
1107
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._hover(progress, options)));
1113
1108
  }, options.timeout);
1114
1109
  }
1115
1110
  async selectOption(metadata, selector, elements, values, options) {
1116
- const controller = new import_progress.ProgressController(metadata, this);
1111
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1117
1112
  return controller.run(async (progress) => {
1118
1113
  return await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._selectOption(progress, elements, values, options));
1119
1114
  }, options.timeout);
1120
1115
  }
1121
1116
  async setInputFiles(metadata, selector, params) {
1122
1117
  const inputFileItems = await (0, import_fileUploadUtils.prepareFilesForUpload)(this, params);
1123
- const controller = new import_progress.ProgressController(metadata, this);
1118
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1124
1119
  return controller.run(async (progress) => {
1125
1120
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, params.strict, true, (handle) => handle._setInputFiles(progress, inputFileItems)));
1126
1121
  }, params.timeout);
1127
1122
  }
1128
1123
  async type(metadata, selector, text, options) {
1129
- const controller = new import_progress.ProgressController(metadata, this);
1124
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1130
1125
  return controller.run(async (progress) => {
1131
1126
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._type(progress, text, options)));
1132
1127
  }, options.timeout);
1133
1128
  }
1134
1129
  async press(metadata, selector, key, options) {
1135
- const controller = new import_progress.ProgressController(metadata, this);
1130
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1136
1131
  return controller.run(async (progress) => {
1137
1132
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._press(progress, key, options)));
1138
1133
  }, options.timeout);
1139
1134
  }
1140
1135
  async check(metadata, selector, options) {
1141
- const controller = new import_progress.ProgressController(metadata, this);
1136
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1142
1137
  return controller.run(async (progress) => {
1143
1138
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._setChecked(progress, true, options)));
1144
1139
  }, options.timeout);
1145
1140
  }
1146
1141
  async uncheck(metadata, selector, options) {
1147
- const controller = new import_progress.ProgressController(metadata, this);
1142
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1148
1143
  return controller.run(async (progress) => {
1149
1144
  return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._setChecked(progress, false, options)));
1150
1145
  }, options.timeout);
1151
1146
  }
1152
1147
  async waitForTimeout(metadata, timeout) {
1153
- const controller = new import_progress.ProgressController(metadata, this);
1154
- return controller.run(async () => {
1155
- await new Promise((resolve) => setTimeout(resolve, timeout));
1156
- });
1148
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1149
+ return controller.run((progress) => progress.wait(timeout));
1157
1150
  }
1158
1151
  async ariaSnapshot(metadata, selector, options) {
1159
1152
  const controller = new import_progress.ProgressController(metadata, this);
@@ -1174,7 +1167,8 @@ class Frame extends import_instrumentation.SdkObject {
1174
1167
  const start = timeout > 0 ? (0, import_utils.monotonicTime)() : 0;
1175
1168
  await new import_progress.ProgressController(metadata, this).run(async (progress) => {
1176
1169
  progress.log(`${(0, import_utils.renderTitleForCall)(metadata)}${timeout ? ` with timeout ${timeout}ms` : ""}`);
1177
- progress.log(`waiting for ${this._asLocator(selector)}`);
1170
+ if (selector)
1171
+ progress.log(`waiting for ${this._asLocator(selector)}`);
1178
1172
  await this._page.performActionPreChecks(progress);
1179
1173
  }, timeout);
1180
1174
  try {
@@ -1184,7 +1178,7 @@ class Frame extends import_instrumentation.SdkObject {
1184
1178
  if (resultOneShot.matches !== options.isNot)
1185
1179
  return resultOneShot;
1186
1180
  } catch (e) {
1187
- if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
1181
+ if ((0, import_progress.isAbortError)(e) || js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
1188
1182
  throw e;
1189
1183
  }
1190
1184
  if (timeout > 0) {
@@ -1215,7 +1209,7 @@ class Frame extends import_instrumentation.SdkObject {
1215
1209
  }
1216
1210
  }
1217
1211
  async _expectInternal(progress, selector, options, lastIntermediateResult) {
1218
- const selectorInFrame = await this.selectors.resolveFrameForSelector(selector, { strict: true });
1212
+ const selectorInFrame = selector ? await this.selectors.resolveFrameForSelector(selector, { strict: true }) : void 0;
1219
1213
  progress.throwIfAborted();
1220
1214
  const { frame, info } = selectorInFrame || { frame: this, info: void 0 };
1221
1215
  const world = options.expression === "to.have.property" ? "main" : info?.world ?? "utility";
@@ -1342,16 +1336,15 @@ class Frame extends import_instrumentation.SdkObject {
1342
1336
  this._parentFrame = null;
1343
1337
  }
1344
1338
  async _callOnElementOnceMatches(metadata, selector, body, taskData, options, scope) {
1345
- const callbackText = body.toString();
1346
- const controller = new import_progress.ProgressController(metadata, this);
1339
+ const controller = new import_progress.ProgressController(metadata, this, "strict");
1347
1340
  return controller.run(async (progress) => {
1341
+ const callbackText = body.toString();
1348
1342
  progress.log(`waiting for ${this._asLocator(selector)}`);
1349
1343
  const promise = this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling) => {
1350
- const resolved = await this.selectors.resolveInjectedForSelector(selector, options, scope);
1351
- progress.throwIfAborted();
1344
+ const resolved = await progress.race(this.selectors.resolveInjectedForSelector(selector, options, scope));
1352
1345
  if (!resolved)
1353
1346
  return continuePolling;
1354
- const { log, success, value } = await resolved.injected.evaluate((injected, { info, callbackText: callbackText2, taskData: taskData2, callId, root }) => {
1347
+ const { log, success, value } = await progress.race(resolved.injected.evaluate((injected, { info, callbackText: callbackText2, taskData: taskData2, callId, root }) => {
1355
1348
  const callback = injected.eval(callbackText2);
1356
1349
  const element = injected.querySelector(info.parsed, root || document, info.strict);
1357
1350
  if (!element)
@@ -1360,7 +1353,7 @@ class Frame extends import_instrumentation.SdkObject {
1360
1353
  if (callId)
1361
1354
  injected.markTargetElements(/* @__PURE__ */ new Set([element]), callId);
1362
1355
  return { log: log2, success: true, value: callback(injected, element, taskData2) };
1363
- }, { info: resolved.info, callbackText, taskData, callId: progress.metadata.id, root: resolved.frame === this ? scope : void 0 });
1356
+ }, { info: resolved.info, callbackText, taskData, callId: progress.metadata.id, root: resolved.frame === this ? scope : void 0 }));
1364
1357
  if (log)
1365
1358
  progress.log(log);
1366
1359
  if (!success)
@@ -1453,26 +1446,27 @@ class SignalBarrier {
1453
1446
  }
1454
1447
  waitFor() {
1455
1448
  this.release();
1456
- return this._promise;
1449
+ return this._progress.race(this._promise);
1457
1450
  }
1458
- async addFrameNavigation(frame) {
1451
+ addFrameNavigation(frame) {
1459
1452
  if (frame.parentFrame())
1460
1453
  return;
1461
1454
  this.retain();
1462
- const waiter = import_helper.helper.waitForEvent(null, frame, Frame.Events.InternalNavigation, (e) => {
1455
+ const waiter = import_helper.helper.waitForEvent(this._progress, frame, Frame.Events.InternalNavigation, (e) => {
1463
1456
  if (!e.isPublic)
1464
1457
  return false;
1465
1458
  if (!e.error && this._progress)
1466
1459
  this._progress.log(` navigated to "${frame._url}"`);
1467
1460
  return true;
1468
1461
  });
1469
- await import_utils.LongStandingScope.raceMultiple([
1462
+ import_utils.LongStandingScope.raceMultiple([
1470
1463
  frame._page.openScope,
1471
1464
  frame._detachedScope
1472
1465
  ], waiter.promise).catch(() => {
1466
+ }).finally(() => {
1467
+ waiter.dispose();
1468
+ this.release();
1473
1469
  });
1474
- waiter.dispose();
1475
- this.release();
1476
1470
  }
1477
1471
  retain() {
1478
1472
  ++this._protectCount;
@@ -65,8 +65,7 @@ class Helper {
65
65
  }));
66
66
  });
67
67
  const dispose = () => import_eventsHelper.eventsHelper.removeEventListeners(listeners);
68
- if (progress)
69
- progress.cleanupWhenAborted(dispose);
68
+ progress.cleanupWhenAborted(dispose);
70
69
  return { promise, dispose };
71
70
  }
72
71
  static secondsToRoundishMillis(value) {
@@ -49,7 +49,7 @@ class Keyboard {
49
49
  this._page = page;
50
50
  }
51
51
  async down(metadata, key) {
52
- const controller = new import_progress.ProgressController(metadata, this._page);
52
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
53
53
  return controller.run((progress) => this._down(progress, key));
54
54
  }
55
55
  async _down(progress, key) {
@@ -71,7 +71,7 @@ class Keyboard {
71
71
  return description;
72
72
  }
73
73
  async up(metadata, key) {
74
- const controller = new import_progress.ProgressController(metadata, this._page);
74
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
75
75
  return controller.run((progress) => this._up(progress, key));
76
76
  }
77
77
  async _up(progress, key) {
@@ -82,14 +82,14 @@ class Keyboard {
82
82
  await this._raw.keyup(progress, this._pressedModifiers, key, description);
83
83
  }
84
84
  async insertText(metadata, text) {
85
- const controller = new import_progress.ProgressController(metadata, this._page);
85
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
86
86
  return controller.run((progress) => this._insertText(progress, text));
87
87
  }
88
88
  async _insertText(progress, text) {
89
89
  await this._raw.sendText(progress, text);
90
90
  }
91
91
  async type(metadata, text, options) {
92
- const controller = new import_progress.ProgressController(metadata, this._page);
92
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
93
93
  return controller.run((progress) => this._type(progress, text, options));
94
94
  }
95
95
  async _type(progress, text, options) {
@@ -99,13 +99,13 @@ class Keyboard {
99
99
  await this._press(progress, char, { delay });
100
100
  } else {
101
101
  if (delay)
102
- await wait(progress, delay);
102
+ await progress.wait(delay);
103
103
  await this._insertText(progress, char);
104
104
  }
105
105
  }
106
106
  }
107
107
  async press(metadata, key, options) {
108
- const controller = new import_progress.ProgressController(metadata, this._page);
108
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
109
109
  return controller.run((progress) => this._press(progress, key, options));
110
110
  }
111
111
  async _press(progress, key, options = {}) {
@@ -129,7 +129,7 @@ class Keyboard {
129
129
  await this._down(progress, tokens[i]);
130
130
  await this._down(progress, key);
131
131
  if (options.delay)
132
- await wait(progress, options.delay);
132
+ await progress.wait(options.delay);
133
133
  await this._up(progress, key);
134
134
  for (let i = tokens.length - 2; i >= 0; --i)
135
135
  await this._up(progress, tokens[i]);
@@ -177,7 +177,7 @@ class Mouse {
177
177
  return { x: this._x, y: this._y };
178
178
  }
179
179
  async move(metadata, x, y, options) {
180
- const controller = new import_progress.ProgressController(metadata, this._page);
180
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
181
181
  return controller.run((progress) => this._move(progress, x, y, options));
182
182
  }
183
183
  async _move(progress, x, y, options = {}) {
@@ -193,7 +193,7 @@ class Mouse {
193
193
  }
194
194
  }
195
195
  async down(metadata, options) {
196
- const controller = new import_progress.ProgressController(metadata, this._page);
196
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
197
197
  return controller.run((progress) => this._down(progress, options));
198
198
  }
199
199
  async _down(progress, options = {}) {
@@ -203,7 +203,7 @@ class Mouse {
203
203
  await this._raw.down(progress, this._x, this._y, this._lastButton, this._buttons, this._keyboard._modifiers(), clickCount);
204
204
  }
205
205
  async up(metadata, options) {
206
- const controller = new import_progress.ProgressController(metadata, this._page);
206
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
207
207
  return controller.run((progress) => this._up(progress, options));
208
208
  }
209
209
  async _up(progress, options = {}) {
@@ -213,7 +213,7 @@ class Mouse {
213
213
  await this._raw.up(progress, this._x, this._y, button, this._buttons, this._keyboard._modifiers(), clickCount);
214
214
  }
215
215
  async click(metadata, x, y, options) {
216
- const controller = new import_progress.ProgressController(metadata, this._page);
216
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
217
217
  return controller.run((progress) => this._click(progress, x, y, options));
218
218
  }
219
219
  async _click(progress, x, y, options = {}) {
@@ -222,10 +222,10 @@ class Mouse {
222
222
  this._move(progress, x, y, { forClick: true });
223
223
  for (let cc = 1; cc <= clickCount; ++cc) {
224
224
  await this._down(progress, { ...options, clickCount: cc });
225
- await wait(progress, delay);
225
+ await progress.wait(delay);
226
226
  await this._up(progress, { ...options, clickCount: cc });
227
227
  if (cc < clickCount)
228
- await wait(progress, delay);
228
+ await progress.wait(delay);
229
229
  }
230
230
  } else {
231
231
  const promises = [];
@@ -238,7 +238,7 @@ class Mouse {
238
238
  }
239
239
  }
240
240
  async wheel(metadata, deltaX, deltaY) {
241
- const controller = new import_progress.ProgressController(metadata, this._page);
241
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
242
242
  return controller.run(async (progress) => {
243
243
  await this._raw.wheel(progress, this._x, this._y, this._buttons, this._keyboard._modifiers(), deltaX, deltaY);
244
244
  });
@@ -295,7 +295,7 @@ class Touchscreen {
295
295
  this._page = page;
296
296
  }
297
297
  async tap(metadata, x, y) {
298
- const controller = new import_progress.ProgressController(metadata, this._page);
298
+ const controller = new import_progress.ProgressController(metadata, this._page, "strict");
299
299
  return controller.run((progress) => this._tap(progress, x, y));
300
300
  }
301
301
  async _tap(progress, x, y) {
@@ -304,10 +304,6 @@ class Touchscreen {
304
304
  await this._raw.tap(progress, x, y, this._page.keyboard._modifiers());
305
305
  }
306
306
  }
307
- async function wait(progress, ms) {
308
- await new Promise((f) => setTimeout(f, Math.min(ms, progress.timeUntilDeadline())));
309
- progress.throwIfAborted();
310
- }
311
307
  // Annotate the CommonJS export names for ESM import in node:
312
308
  0 && (module.exports = {
313
309
  Keyboard,
@@ -55,6 +55,7 @@ var import_manualPromise = require("../utils/isomorphic/manualPromise");
55
55
  var import_utilityScriptSerializers = require("../utils/isomorphic/utilityScriptSerializers");
56
56
  var import_callLog = require("./callLog");
57
57
  var rawBindingsControllerSource = __toESM(require("../generated/bindingsControllerSource"));
58
+ var import_protocolError = require("./protocolError");
58
59
  class Page extends import_instrumentation.SdkObject {
59
60
  constructor(delegate, browserContext) {
60
61
  super(browserContext, "page");
@@ -340,7 +341,7 @@ class Page extends import_instrumentation.SdkObject {
340
341
  return;
341
342
  for (const [uid, handler] of this._locatorHandlers) {
342
343
  if (!handler.resolved) {
343
- if (await this.mainFrame().isVisibleInternal(handler.selector, { strict: true })) {
344
+ if (await this.mainFrame().isVisibleInternal(progress, handler.selector, { strict: true })) {
344
345
  handler.resolved = new import_manualPromise.ManualPromise();
345
346
  this.emit(Page.Events.LocatorHandlerTriggered, uid);
346
347
  }
@@ -357,8 +358,7 @@ class Page extends import_instrumentation.SdkObject {
357
358
  progress.log(` locator handler has finished`);
358
359
  }
359
360
  });
360
- await this.openScope.race(promise).finally(() => --this._locatorHandlerRunningCounter);
361
- progress.throwIfAborted();
361
+ await progress.race(this.openScope.race(promise)).finally(() => --this._locatorHandlerRunningCounter);
362
362
  progress.log(` interception handler has finished, continuing`);
363
363
  }
364
364
  }
@@ -784,7 +784,7 @@ async function snapshotFrameForAI(metadata, frame, frameOrdinal, frameIds) {
784
784
  return continuePolling;
785
785
  return snapshotOrRetry;
786
786
  } catch (e) {
787
- if (js.isJavaScriptErrorInEvaluate(e))
787
+ if ((0, import_progress.isAbortError)(e) || (0, import_protocolError.isSessionClosedError)(e) || js.isJavaScriptErrorInEvaluate(e))
788
788
  throw e;
789
789
  return continuePolling;
790
790
  }