evaluate method
Evaluates expression on global object.
returnByValue
: Whether the result is expected to be a JSON object that should be sent by value.contextId
: Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page.awaitPromise
: Whether execution should await for resulting value and return once awaited promise is resolved.
Implementation
Future<RemoteObject> evaluate(
String expression, {
bool? returnByValue,
int? contextId,
bool? awaitPromise,
}) async {
Map<String, dynamic> params = {
'expression': expression,
};
if (returnByValue != null) {
params['returnByValue'] = returnByValue;
}
if (contextId != null) {
params['contextId'] = contextId;
}
if (awaitPromise != null) {
params['awaitPromise'] = awaitPromise;
}
final WipResponse response =
await sendCommand('Runtime.evaluate', params: params);
if (response.result!.containsKey('exceptionDetails')) {
throw ExceptionDetails(
response.result!['exceptionDetails'] as Map<String, dynamic>);
} else {
return RemoteObject(response.result!['result'] as Map<String, dynamic>);
}
}