patchright-core 1.52.3 → 1.52.5

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.
@@ -192,9 +192,9 @@ class Frame extends import_channelOwner.ChannelOwner {
192
192
  const result = await this._channel.evalOnSelector({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
193
193
  return (0, import_jsHandle.parseResult)(result.value);
194
194
  }
195
- async $$eval(selector, pageFunction, arg) {
196
- (0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
197
- const result = await this._channel.evalOnSelectorAll({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
195
+ async $$eval(selector, pageFunction, arg, isolatedContext = true) {
196
+ (0, import_jsHandle.assertMaxArguments)(arguments.length, 4);
197
+ const result = await this._channel.evalOnSelectorAll({ selector, expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg), isolatedContext });
198
198
  return (0, import_jsHandle.parseResult)(result.value);
199
199
  }
200
200
  async $$(selector) {
@@ -112,8 +112,8 @@ class Locator {
112
112
  options?.timeout
113
113
  );
114
114
  }
115
- async evaluateAll(pageFunction, arg) {
116
- return await this._frame.$$eval(this._selector, pageFunction, arg);
115
+ async evaluateAll(pageFunction, arg, isolatedContext = true) {
116
+ return await this._frame.$$eval(this._selector, pageFunction, arg, isolatedContext);
117
117
  }
118
118
  async evaluateHandle(pageFunction, arg, options, isolatedContext = true) {
119
119
  return await this._withElement(
@@ -1464,7 +1464,8 @@ import_validatorPrimitives.scheme.FrameEvalOnSelectorAllParams = (0, import_vali
1464
1464
  selector: import_validatorPrimitives.tString,
1465
1465
  expression: import_validatorPrimitives.tString,
1466
1466
  isFunction: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tBoolean),
1467
- arg: (0, import_validatorPrimitives.tType)("SerializedArgument")
1467
+ arg: (0, import_validatorPrimitives.tType)("SerializedArgument"),
1468
+ isolatedContext: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tBoolean)
1468
1469
  });
1469
1470
  import_validatorPrimitives.scheme.FrameEvalOnSelectorAllResult = (0, import_validatorPrimitives.tObject)({
1470
1471
  value: (0, import_validatorPrimitives.tType)("SerializedValue")
@@ -518,11 +518,11 @@ class RouteImpl {
518
518
  if (overrides.url && (overrides.url === "http://patchright-init-script-inject.internal/" || overrides.url === "https://patchright-init-script-inject.internal/")) {
519
519
  await catchDisallowedErrors(async () => {
520
520
  this._sessionManager._alreadyTrackedNetworkIds.add(this._networkId);
521
- this._session.send("Fetch.continueRequest", { requestId: this._interceptionId, interceptResponse: true });
521
+ this._session._sendMayFail("Fetch.continueRequest", { requestId: this._interceptionId, interceptResponse: true });
522
522
  });
523
523
  } else {
524
524
  await catchDisallowedErrors(async () => {
525
- await this._session.send("Fetch.continueRequest", this._alreadyContinuedParams);
525
+ await this._session._sendMayFail("Fetch.continueRequest", this._alreadyContinuedParams);
526
526
  });
527
527
  }
528
528
  }
@@ -552,7 +552,8 @@ class RouteImpl {
552
552
  let injectionHTML = "";
553
553
  allInjections.forEach((script) => {
554
554
  let scriptId = import_crypto.default.randomBytes(22).toString("hex");
555
- injectionHTML += `<script class="${this._page._delegate.initScriptTag}" nonce="${scriptNonce}" type="text/javascript">document.getElementById("${scriptId}")?.remove();${script.source}</script>`;
555
+ let scriptSource = script.source || script;
556
+ injectionHTML += `<script class="${this._page._delegate.initScriptTag}" nonce="${scriptNonce}" type="text/javascript">document.getElementById("${scriptId}")?.remove();${scriptSource}</script>`;
556
557
  });
557
558
  if (response.isBase64) {
558
559
  response.isBase64 = false;
@@ -495,7 +495,6 @@ class FrameSession {
495
495
  }
496
496
  async _navigate(frame, url, referrer) {
497
497
  const response = await this._client.send("Page.navigate", { url, referrer, frameId: frame._id, referrerPolicy: "unsafeUrl" });
498
- this._client._sendMayFail("Page.waitForDebugger");
499
498
  if (response.errorText)
500
499
  throw new frames.NavigationAbortedError(response.loaderId, `${response.errorText} at ${url}`);
501
500
  return { newDocumentId: response.loaderId };
@@ -94,7 +94,7 @@ class FrameDispatcher extends import_dispatcher.Dispatcher {
94
94
  return { value: (0, import_jsHandleDispatcher.serializeResult)(await this._frame.evalOnSelector(params.selector, !!params.strict, params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg))) };
95
95
  }
96
96
  async evalOnSelectorAll(params, metadata) {
97
- return { value: (0, import_jsHandleDispatcher.serializeResult)(await this._frame.evalOnSelectorAll(params.selector, params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg))) };
97
+ return { value: (0, import_jsHandleDispatcher.serializeResult)(await this._frame.evalOnSelectorAll(params.selector, params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg), null, params.isolatedContext)) };
98
98
  }
99
99
  async querySelector(params, metadata) {
100
100
  return { element: import_elementHandlerDispatcher.ElementHandleDispatcher.fromNullable(this, await this._frame.querySelector(params.selector, params)) };
@@ -46,8 +46,8 @@ class FrameSelectors {
46
46
  }
47
47
  return adoptIfNeeded(elementHandle, await resolved.frame._mainContext());
48
48
  }
49
- async queryArrayInMainWorld(selector, scope) {
50
- const resolved = await this.resolveInjectedForSelector(selector, { mainWorld: true }, scope);
49
+ async queryArrayInMainWorld(selector, scope, isolatedContext) {
50
+ const resolved = await this.resolveInjectedForSelector(selector, { mainWorld: !isolatedContext }, scope);
51
51
  if (!resolved)
52
52
  throw new Error(`Failed to find frame for selector "${selector}"`);
53
53
  return await resolved.injected.evaluateHandle((injected, { info, scope: scope2 }) => {
@@ -612,6 +612,7 @@ class Frame extends import_instrumentation.SdkObject {
612
612
  return this._page._delegate.getFrameElement(this);
613
613
  }
614
614
  async _context(world) {
615
+ if (this.isDetached()) throw new Error("Frame was detached");
615
616
  try {
616
617
  var client = this._page._delegate._sessionForFrame(this)._client;
617
618
  } catch (e) {
@@ -756,7 +757,7 @@ class Frame extends import_instrumentation.SdkObject {
756
757
  } catch (e) {
757
758
  return "internal:continuepolling";
758
759
  }
759
- });
760
+ }, "returnOnNotResolved");
760
761
  return scope ? scope._context._raceAgainstContextDestroyed(promise) : promise;
761
762
  }
762
763
  async dispatchEvent(metadata, selector, type, eventInit = {}, options = {}, scope) {
@@ -767,16 +768,21 @@ class Frame extends import_instrumentation.SdkObject {
767
768
  async evalOnSelector(selector, strict, expression, isFunction, arg, scope) {
768
769
  const handle = await this.selectors.query(selector, { strict }, scope);
769
770
  if (!handle)
770
- throw new Error(`Failed to find element matching selector "${selector}"`);
771
- const result = await handle.evaluateExpression(expression, { isFunction }, arg);
771
+ throw new Error("Failed to find element matching selector " + selector);
772
+ const result = await handle.evaluateExpression(expression, { isFunction }, arg, true);
772
773
  handle.dispose();
773
774
  return result;
774
775
  }
775
- async evalOnSelectorAll(selector, expression, isFunction, arg, scope) {
776
- const arrayHandle = await this.selectors.queryArrayInMainWorld(selector, scope);
777
- const result = await arrayHandle.evaluateExpression(expression, { isFunction }, arg);
778
- arrayHandle.dispose();
779
- return result;
776
+ async evalOnSelectorAll(selector, expression, isFunction, arg, scope, isolatedContext) {
777
+ try {
778
+ const arrayHandle = await this.selectors.queryArrayInMainWorld(selector, scope, isolatedContext);
779
+ const result = await arrayHandle.evaluateExpression(expression, { isFunction }, arg, isolatedContext);
780
+ arrayHandle.dispose();
781
+ return result;
782
+ } catch (e) {
783
+ if ("JSHandles can be evaluated only in the context they were created!" === e.message) return await this.evalOnSelectorAll(selector, expression, isFunction, arg, scope, isolatedContext);
784
+ throw e;
785
+ }
780
786
  }
781
787
  async maskSelectors(selectors, color) {
782
788
  const context = await this._utilityContext();
@@ -789,14 +795,16 @@ class Frame extends import_instrumentation.SdkObject {
789
795
  return this.selectors.queryAll(selector);
790
796
  }
791
797
  async queryCount(selector) {
792
- const custom_metadata = {
798
+ const customMetadata = {
793
799
  "internal": false,
794
- "log": []
800
+ "log": [],
801
+ "method": "queryCount"
795
802
  };
796
- const controller = new import_progress.ProgressController(custom_metadata, this);
803
+ const controller = new import_progress.ProgressController(customMetadata, this);
797
804
  const resultPromise = await controller.run(async (progress) => {
798
805
  progress.log("waiting for " + this._asLocator(selector));
799
- const promise = await this._retryWithProgressIfNotConnected(progress, selector, false, false, async (result) => {
806
+ const promise = await this._retryWithProgressIfNotConnected(progress, selector, null, false, async (result) => {
807
+ if (!result) return 0;
800
808
  const handle = result[0];
801
809
  const handles = result[1];
802
810
  return handle ? handles.length : 0;
@@ -978,7 +986,7 @@ class Frame extends import_instrumentation.SdkObject {
978
986
  return result;
979
987
  }
980
988
  async retryWithProgressAndTimeouts(progress, timeouts, action) {
981
- const continuePolling2 = Symbol("continuePolling");
989
+ const continuePolling = Symbol("continuePolling");
982
990
  timeouts = [0, ...timeouts];
983
991
  let timeoutIndex = 0;
984
992
  while (progress.isRunning()) {
@@ -992,8 +1000,8 @@ class Frame extends import_instrumentation.SdkObject {
992
1000
  }
993
1001
  progress.throwIfAborted();
994
1002
  try {
995
- const result = await action(continuePolling2);
996
- if (result === continuePolling2)
1003
+ const result = await action(continuePolling);
1004
+ if (result === continuePolling)
997
1005
  continue;
998
1006
  return result;
999
1007
  } catch (e) {
@@ -1016,34 +1024,49 @@ class Frame extends import_instrumentation.SdkObject {
1016
1024
  }
1017
1025
  async _retryWithProgressIfNotConnected(progress, selector, strict, performActionPreChecks, action, returnAction) {
1018
1026
  progress.log("waiting for " + this._asLocator(selector));
1019
- return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling2) => {
1027
+ return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling) => {
1020
1028
  if (performActionPreChecks) await this._page.performActionPreChecks(progress);
1021
1029
  const resolved = await this.selectors.resolveInjectedForSelector(selector, {
1022
1030
  strict
1023
1031
  });
1024
1032
  progress.throwIfAborted();
1025
1033
  if (!resolved) {
1026
- if (returnAction === "returnOnNotResolved" || returnAction === "returnAll") return null;
1027
- return continuePolling2;
1034
+ if (returnAction === "returnOnNotResolved" || returnAction === "returnAll") {
1035
+ const result2 = await action(null);
1036
+ return result2 === "internal:continuepolling" ? continuePolling2 : result2;
1037
+ }
1038
+ return continuePolling;
1028
1039
  }
1029
1040
  try {
1030
1041
  var client = this._page._delegate._sessionForFrame(resolved.frame)._client;
1031
1042
  } catch (e) {
1032
1043
  var client = this._page._delegate._mainFrameSession._client;
1033
1044
  }
1034
- var context = await resolved.frame._context("main");
1045
+ var utilityContext = await resolved.frame._utilityContext();
1046
+ var mainContext = await resolved.frame._mainContext();
1035
1047
  const documentNode = await client.send("Runtime.evaluate", {
1036
1048
  expression: "document",
1037
1049
  serializationOptions: {
1038
1050
  serialization: "idOnly"
1039
1051
  },
1040
- contextId: context.delegate._contextId
1052
+ contextId: utilityContext.delegate._contextId
1041
1053
  });
1042
- const documentScope = new dom.ElementHandle(context, documentNode.result.objectId);
1043
- const currentScopingElements = await this._customFindElementsByParsed(resolved, client, context, documentScope, progress, resolved.info.parsed);
1054
+ const documentScope = new dom.ElementHandle(utilityContext, documentNode.result.objectId);
1055
+ let currentScopingElements;
1056
+ try {
1057
+ currentScopingElements = await this._customFindElementsByParsed(resolved, client, mainContext, documentScope, progress, resolved.info.parsed);
1058
+ } catch (e) {
1059
+ if ("JSHandles can be evaluated only in the context they were created!" === e.message) return continuePolling3;
1060
+ await resolved.injected.evaluateHandle((injected, { error }) => {
1061
+ throw error;
1062
+ }, { error: e });
1063
+ }
1044
1064
  if (currentScopingElements.length == 0) {
1045
- if (returnAction === "returnOnNotResolved" || returnAction === "returnAll") return null;
1046
- return continuePolling2;
1065
+ if (returnAction === "returnOnNotResolved" || returnAction === "returnAll") {
1066
+ const result2 = await action(null);
1067
+ return result2 === "internal:continuepolling" ? continuePolling2 : result2;
1068
+ }
1069
+ return continuePolling;
1047
1070
  }
1048
1071
  const resultElement = currentScopingElements[0];
1049
1072
  if (currentScopingElements.length > 1) {
@@ -1071,9 +1094,9 @@ class Frame extends import_instrumentation.SdkObject {
1071
1094
  }
1072
1095
  if (result === "error:notconnected") {
1073
1096
  progress.log("element was detached from the DOM, retrying");
1074
- return continuePolling2;
1097
+ return continuePolling;
1075
1098
  } else if (result === "internal:continuepolling") {
1076
- return continuePolling2;
1099
+ return continuePolling;
1077
1100
  }
1078
1101
  return result;
1079
1102
  } finally {
@@ -1209,11 +1232,12 @@ class Frame extends import_instrumentation.SdkObject {
1209
1232
  }
1210
1233
  async isVisibleInternal(selector, options = {}, scope) {
1211
1234
  try {
1212
- const custom_metadata = { "internal": false, "log": [] };
1213
- const controller = new import_progress.ProgressController(custom_metadata, this);
1235
+ const customMetadata = { "internal": false, "log": [], "method": "isVisible" };
1236
+ const controller = new import_progress.ProgressController(customMetadata, this);
1214
1237
  return await controller.run(async (progress) => {
1215
1238
  progress.log("waiting for " + this._asLocator(selector));
1216
1239
  const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, false, async (handle) => {
1240
+ if (!handle) return false;
1217
1241
  if (handle.parentNode.constructor.name == "ElementHandle") {
1218
1242
  return await handle.parentNode.evaluateInUtility(([injected, node, { handle: handle2 }]) => {
1219
1243
  const state = handle2 ? injected.elementState(handle2, "visible") : {
@@ -1342,11 +1366,11 @@ class Frame extends import_instrumentation.SdkObject {
1342
1366
  if (timeout < 0)
1343
1367
  return { matches: options.isNot, log: (0, import_callLog.compressCallLog)(metadata.log), timedOut: true, received: lastIntermediateResult.received };
1344
1368
  return await new import_progress.ProgressController(metadata, this).run(async (progress) => {
1345
- return await this.retryWithProgressAndTimeouts(progress, [100, 250, 500, 1e3], async (continuePolling2) => {
1369
+ return await this.retryWithProgressAndTimeouts(progress, [100, 250, 500, 1e3], async (continuePolling) => {
1346
1370
  await this._page.performActionPreChecks(progress);
1347
1371
  const { matches, received } = await this._expectInternal(progress, selector, options, lastIntermediateResult);
1348
1372
  if (matches === options.isNot) {
1349
- return continuePolling2;
1373
+ return continuePolling;
1350
1374
  }
1351
1375
  return { matches, received };
1352
1376
  });
@@ -1366,6 +1390,21 @@ class Frame extends import_instrumentation.SdkObject {
1366
1390
  progress.log("waiting for " + this._asLocator(selector));
1367
1391
  const isArray = options.expression === "to.have.count" || options.expression.endsWith(".array");
1368
1392
  const promise = await this._retryWithProgressIfNotConnected(progress, selector, !isArray, false, async (result) => {
1393
+ if (!result) {
1394
+ if (options.expectedNumber === 0)
1395
+ return { matches: true };
1396
+ if (!options.isNot && options.expression === "to.be.hidden")
1397
+ return { matches: true };
1398
+ if (options.isNot && options.expression === "to.be.visible")
1399
+ return { matches: false };
1400
+ if (!options.isNot && options.expression === "to.be.detached")
1401
+ return { matches: true };
1402
+ if (options.isNot && options.expression === "to.be.attached")
1403
+ return { matches: false };
1404
+ if (options.isNot && options.expression === "to.be.in.viewport")
1405
+ return { matches: false };
1406
+ return { matches: options.isNot, missingReceived: true };
1407
+ }
1369
1408
  const handle = result[0];
1370
1409
  const handles = result[1];
1371
1410
  if (handle.parentNode.constructor.name == "ElementHandle") {
@@ -1498,7 +1537,7 @@ class Frame extends import_instrumentation.SdkObject {
1498
1537
  const controller = new import_progress.ProgressController(metadata, this);
1499
1538
  return controller.run(async (progress) => {
1500
1539
  progress.log("waiting for " + this._asLocator(selector));
1501
- const promise = this._retryWithProgressIfNotConnected(progress, selector, false, false, async (handle) => {
1540
+ const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, false, async (handle) => {
1502
1541
  if (handle.parentNode.constructor.name == "ElementHandle") {
1503
1542
  return await handle.parentNode.evaluateInUtility(([injected, node, { callbackText: callbackText2, handle: handle2, taskData: taskData2 }]) => {
1504
1543
  const callback = injected.eval(callbackText2);
@@ -1624,8 +1663,8 @@ class Frame extends import_instrumentation.SdkObject {
1624
1663
  var elementsIndexes = [];
1625
1664
  if (part.name == "nth") {
1626
1665
  const partNth = Number(part.body);
1627
- if (partNth > currentScopingElements.length || partNth < -currentScopingElements.length) {
1628
- return continuePolling;
1666
+ if (partNth > currentScopingElements.length - 1 || partNth < -(currentScopingElements.length - 1)) {
1667
+ throw new Error("Can't query n-th element");
1629
1668
  } else {
1630
1669
  currentScopingElements = [currentScopingElements.at(partNth)];
1631
1670
  continue;
@@ -1693,7 +1732,7 @@ class Frame extends import_instrumentation.SdkObject {
1693
1732
  callId: progress.metadata.id
1694
1733
  });
1695
1734
  const rootElementsAmount = await rootElements.getProperty("length");
1696
- queryingElements.push([rootElements, rootElementsAmount, resolved.injected]);
1735
+ queryingElements.push([rootElements, rootElementsAmount, scope]);
1697
1736
  for (var queryedElement of queryingElements) {
1698
1737
  var elementsToCheck = queryedElement[0];
1699
1738
  var elementsAmount = await queryedElement[1].jsonValue();
@@ -1722,6 +1761,7 @@ class Frame extends import_instrumentation.SdkObject {
1722
1761
  currentScopingElements = [];
1723
1762
  for (var element of elements) {
1724
1763
  var elemIndex = element.backendNodeId;
1764
+ if (elementsIndexes.includes(elemIndex)) continue;
1725
1765
  var elemPos = elementsIndexes.findIndex((index) => index > elemIndex);
1726
1766
  if (elemPos === -1) {
1727
1767
  currentScopingElements.push(element);
@@ -134,7 +134,7 @@ class JSHandle extends import_instrumentation.SdkObject {
134
134
  }
135
135
  async evaluateExpressionHandle(expression, options, arg, isolatedContext) {
136
136
  let context = this._context;
137
- if (this._context.constructor.name === "FrameExecutionContext") {
137
+ if (context.constructor.name === "FrameExecutionContext") {
138
138
  const frame = this._context.frame;
139
139
  if (frame) {
140
140
  if (isolatedContext) context = await frame._utilityContext();
@@ -663,7 +663,7 @@ class Worker extends import_instrumentation.SdkObject {
663
663
  }
664
664
  async evaluateExpressionHandle(expression, isFunction, arg, isolatedContext) {
665
665
  let context = await this._executionContextPromise;
666
- if (this._context.constructor.name === "FrameExecutionContext") {
666
+ if (context.constructor.name === "FrameExecutionContext") {
667
667
  const frame = this._context.frame;
668
668
  if (frame) {
669
669
  if (isolatedContext) context = await frame._utilityContext();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchright-core",
3
- "version": "1.52.3",
3
+ "version": "1.52.5",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": {
6
6
  "type": "git",
package/types/types.d.ts CHANGED
@@ -121,7 +121,7 @@ export interface Page {
121
121
  * @param arg Optional argument to pass to
122
122
  * [`pageFunction`](https://playwright.dev/docs/api/class-page#page-evaluate-option-expression).
123
123
  */
124
- evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg): Promise<R>;
124
+ evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<R>;
125
125
  /**
126
126
  * Returns the value of the
127
127
  * [`pageFunction`](https://playwright.dev/docs/api/class-page#page-evaluate-option-expression) invocation.
@@ -172,7 +172,7 @@ export interface Page {
172
172
  * @param arg Optional argument to pass to
173
173
  * [`pageFunction`](https://playwright.dev/docs/api/class-page#page-evaluate-option-expression).
174
174
  */
175
- evaluate<R>(pageFunction: PageFunction<void, R>, arg?: any): Promise<R>;
175
+ evaluate<R>(pageFunction: PageFunction<void, R>, arg?: any, isolatedContext?: boolean): Promise<R>;
176
176
 
177
177
  /**
178
178
  * Returns the value of the
@@ -218,7 +218,7 @@ export interface Page {
218
218
  * @param arg Optional argument to pass to
219
219
  * [`pageFunction`](https://playwright.dev/docs/api/class-page#page-evaluate-handle-option-expression).
220
220
  */
221
- evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
221
+ evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<SmartHandle<R>>;
222
222
  /**
223
223
  * Returns the value of the
224
224
  * [`pageFunction`](https://playwright.dev/docs/api/class-page#page-evaluate-handle-option-expression) invocation as a
@@ -263,7 +263,7 @@ export interface Page {
263
263
  * @param arg Optional argument to pass to
264
264
  * [`pageFunction`](https://playwright.dev/docs/api/class-page#page-evaluate-handle-option-expression).
265
265
  */
266
- evaluateHandle<R>(pageFunction: PageFunction<void, R>, arg?: any): Promise<SmartHandle<R>>;
266
+ evaluateHandle<R>(pageFunction: PageFunction<void, R>, arg?: any, isolatedContext?: boolean): Promise<SmartHandle<R>>;
267
267
 
268
268
  /**
269
269
  * Adds a script which would be evaluated in one of the following scenarios:
@@ -5260,7 +5260,7 @@ export interface Frame {
5260
5260
  * @param arg Optional argument to pass to
5261
5261
  * [`pageFunction`](https://playwright.dev/docs/api/class-frame#frame-evaluate-option-expression).
5262
5262
  */
5263
- evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg): Promise<R>;
5263
+ evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<R>;
5264
5264
  /**
5265
5265
  * Returns the return value of
5266
5266
  * [`pageFunction`](https://playwright.dev/docs/api/class-frame#frame-evaluate-option-expression).
@@ -5307,7 +5307,7 @@ export interface Frame {
5307
5307
  * @param arg Optional argument to pass to
5308
5308
  * [`pageFunction`](https://playwright.dev/docs/api/class-frame#frame-evaluate-option-expression).
5309
5309
  */
5310
- evaluate<R>(pageFunction: PageFunction<void, R>, arg?: any): Promise<R>;
5310
+ evaluate<R>(pageFunction: PageFunction<void, R>, arg?: any, isolatedContext?: boolean): Promise<R>;
5311
5311
 
5312
5312
  /**
5313
5313
  * Returns the return value of
@@ -5355,7 +5355,7 @@ export interface Frame {
5355
5355
  * @param arg Optional argument to pass to
5356
5356
  * [`pageFunction`](https://playwright.dev/docs/api/class-frame#frame-evaluate-handle-option-expression).
5357
5357
  */
5358
- evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
5358
+ evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<SmartHandle<R>>;
5359
5359
  /**
5360
5360
  * Returns the return value of
5361
5361
  * [`pageFunction`](https://playwright.dev/docs/api/class-frame#frame-evaluate-handle-option-expression) as a
@@ -5402,7 +5402,7 @@ export interface Frame {
5402
5402
  * @param arg Optional argument to pass to
5403
5403
  * [`pageFunction`](https://playwright.dev/docs/api/class-frame#frame-evaluate-handle-option-expression).
5404
5404
  */
5405
- evaluateHandle<R>(pageFunction: PageFunction<void, R>, arg?: any): Promise<SmartHandle<R>>;
5405
+ evaluateHandle<R>(pageFunction: PageFunction<void, R>, arg?: any, isolatedContext?: boolean): Promise<SmartHandle<R>>;
5406
5406
 
5407
5407
  /**
5408
5408
  * **NOTE** Use locator-based [frame.locator(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-locator)
@@ -10239,7 +10239,7 @@ export interface Worker {
10239
10239
  * @param arg Optional argument to pass to
10240
10240
  * [`pageFunction`](https://playwright.dev/docs/api/class-worker#worker-evaluate-option-expression).
10241
10241
  */
10242
- evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg): Promise<R>;
10242
+ evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<R>;
10243
10243
  /**
10244
10244
  * Returns the return value of
10245
10245
  * [`pageFunction`](https://playwright.dev/docs/api/class-worker#worker-evaluate-option-expression).
@@ -10260,7 +10260,7 @@ export interface Worker {
10260
10260
  * @param arg Optional argument to pass to
10261
10261
  * [`pageFunction`](https://playwright.dev/docs/api/class-worker#worker-evaluate-option-expression).
10262
10262
  */
10263
- evaluate<R>(pageFunction: PageFunction<void, R>, arg?: any): Promise<R>;
10263
+ evaluate<R>(pageFunction: PageFunction<void, R>, arg?: any, isolatedContext?: boolean): Promise<R>;
10264
10264
 
10265
10265
  /**
10266
10266
  * Returns the return value of
@@ -10283,7 +10283,7 @@ export interface Worker {
10283
10283
  * @param arg Optional argument to pass to
10284
10284
  * [`pageFunction`](https://playwright.dev/docs/api/class-worker#worker-evaluate-handle-option-expression).
10285
10285
  */
10286
- evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
10286
+ evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<SmartHandle<R>>;
10287
10287
  /**
10288
10288
  * Returns the return value of
10289
10289
  * [`pageFunction`](https://playwright.dev/docs/api/class-worker#worker-evaluate-handle-option-expression) as a
@@ -10305,7 +10305,7 @@ export interface Worker {
10305
10305
  * @param arg Optional argument to pass to
10306
10306
  * [`pageFunction`](https://playwright.dev/docs/api/class-worker#worker-evaluate-handle-option-expression).
10307
10307
  */
10308
- evaluateHandle<R>(pageFunction: PageFunction<void, R>, arg?: any): Promise<SmartHandle<R>>;
10308
+ evaluateHandle<R>(pageFunction: PageFunction<void, R>, arg?: any, isolatedContext?: boolean): Promise<SmartHandle<R>>;
10309
10309
  /**
10310
10310
  * Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is
10311
10311
  * terminated.
@@ -10383,7 +10383,7 @@ export interface JSHandle<T = any> {
10383
10383
  * @param arg Optional argument to pass to
10384
10384
  * [`pageFunction`](https://playwright.dev/docs/api/class-elementhandle#element-handle-evaluate-option-expression).
10385
10385
  */
10386
- evaluate<R, Arg, O extends T = T>(pageFunction: PageFunctionOn<O, Arg, R>, arg: Arg): Promise<R>;
10386
+ evaluate<R, Arg, O extends T = T>(pageFunction: PageFunctionOn<O, Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<R>;
10387
10387
  /**
10388
10388
  * Returns the return value of
10389
10389
  * [`pageFunction`](https://playwright.dev/docs/api/class-elementhandle#element-handle-evaluate-option-expression).
@@ -10405,7 +10405,7 @@ export interface JSHandle<T = any> {
10405
10405
  * @param arg Optional argument to pass to
10406
10406
  * [`pageFunction`](https://playwright.dev/docs/api/class-elementhandle#element-handle-evaluate-option-expression).
10407
10407
  */
10408
- evaluate<R, O extends T = T>(pageFunction: PageFunctionOn<O, void, R>, arg?: any): Promise<R>;
10408
+ evaluate<R, O extends T = T>(pageFunction: PageFunctionOn<O, void, R>, arg?: any, isolatedContext?: boolean): Promise<R>;
10409
10409
 
10410
10410
  /**
10411
10411
  * Returns the return value of
@@ -10427,7 +10427,7 @@ export interface JSHandle<T = any> {
10427
10427
  * @param arg Optional argument to pass to
10428
10428
  * [`pageFunction`](https://playwright.dev/docs/api/class-elementhandle#element-handle-evaluate-handle-option-expression).
10429
10429
  */
10430
- evaluateHandle<R, Arg, O extends T = T>(pageFunction: PageFunctionOn<O, Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
10430
+ evaluateHandle<R, Arg, O extends T = T>(pageFunction: PageFunctionOn<O, Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<SmartHandle<R>>;
10431
10431
  /**
10432
10432
  * Returns the return value of
10433
10433
  * [`pageFunction`](https://playwright.dev/docs/api/class-elementhandle#element-handle-evaluate-handle-option-expression)
@@ -10448,7 +10448,7 @@ export interface JSHandle<T = any> {
10448
10448
  * @param arg Optional argument to pass to
10449
10449
  * [`pageFunction`](https://playwright.dev/docs/api/class-elementhandle#element-handle-evaluate-handle-option-expression).
10450
10450
  */
10451
- evaluateHandle<R, O extends T = T>(pageFunction: PageFunctionOn<O, void, R>, arg?: any): Promise<SmartHandle<R>>;
10451
+ evaluateHandle<R, O extends T = T>(pageFunction: PageFunctionOn<O, void, R>, arg?: any, isolatedContext?: boolean): Promise<SmartHandle<R>>;
10452
10452
 
10453
10453
  /**
10454
10454
  * Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
@@ -12204,7 +12204,7 @@ export interface Locator {
12204
12204
  */
12205
12205
  evaluate<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg: Arg, options?: {
12206
12206
  timeout?: number;
12207
- }): Promise<R>;
12207
+ }, isolatedContext?: boolean): Promise<R>;
12208
12208
  /**
12209
12209
  * Execute JavaScript code in the page, taking the matching element as an argument.
12210
12210
  *
@@ -12229,7 +12229,7 @@ export interface Locator {
12229
12229
  */
12230
12230
  evaluate<R, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, void, R>, options?: {
12231
12231
  timeout?: number;
12232
- }): Promise<R>;
12232
+ }, isolatedContext?: boolean): Promise<R>;
12233
12233
  /**
12234
12234
  * Execute JavaScript code in the page, taking the matching element as an argument, and return a
12235
12235
  * [JSHandle](https://playwright.dev/docs/api/class-jshandle) with the result.
@@ -12262,7 +12262,7 @@ export interface Locator {
12262
12262
  * [`pageFunction`](https://playwright.dev/docs/api/class-locator#locator-evaluate-handle-option-expression).
12263
12263
  * @param options
12264
12264
  */
12265
- evaluateHandle<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
12265
+ evaluateHandle<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg: Arg, isolatedContext?: boolean): Promise<SmartHandle<R>>;
12266
12266
  /**
12267
12267
  * Execute JavaScript code in the page, taking the matching element as an argument, and return a
12268
12268
  * [JSHandle](https://playwright.dev/docs/api/class-jshandle) with the result.
@@ -12295,7 +12295,7 @@ export interface Locator {
12295
12295
  * [`pageFunction`](https://playwright.dev/docs/api/class-locator#locator-evaluate-handle-option-expression).
12296
12296
  * @param options
12297
12297
  */
12298
- evaluateHandle<R, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, void, R>): Promise<SmartHandle<R>>;
12298
+ evaluateHandle<R, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, void, R>, isolatedContext?: boolean): Promise<SmartHandle<R>>;
12299
12299
  /**
12300
12300
  * Execute JavaScript code in the page, taking all matching elements as an argument.
12301
12301
  *