MCPcopy Index your code
hub / github.com/microsoft/playwright / evaluate

Method evaluate

packages/injected/src/utilityScript.ts:66–84  ·  view source on GitHub ↗
(isFunction: boolean | undefined, returnByValue: boolean, expression: string, argCount: number, ...argsAndHandles: any[])

Source from the content-addressed store, hash-verified

64 }
65
66 evaluate(isFunction: boolean | undefined, returnByValue: boolean, expression: string, argCount: number, ...argsAndHandles: any[]) {
67 const args = argsAndHandles.slice(0, argCount);
68 const handles = argsAndHandles.slice(argCount);
69 const parameters = [];
70 for (let i = 0; i < args.length; i++)
71 parameters[i] = parseEvaluationResultValue(args[i], handles);
72
73 let result = this.global.eval(expression);
74 if (isFunction === true) {
75 result = result(...parameters);
76 } else if (isFunction === false) {
77 result = result;
78 } else {
79 // auto detect.
80 if (typeof result === 'function')
81 result = result(...parameters);
82 }
83 return returnByValue ? this._promiseAwareJsonValueNoThrow(result) : result;
84 }
85
86 jsonValue(returnByValue: true, value: any) {
87 // Special handling of undefined to work-around multi-step returnByValue handling in WebKit.

Callers

nothing calls this directly

Calls 4

resultFunction · 0.85
evalMethod · 0.80

Tested by

no test coverage detected