addBinding method

Future<void> addBinding(
  1. String name, {
  2. @Deprecated('This parameter is deprecated') ExecutionContextId? executionContextId,
  3. String? executionContextName,
})

If executionContextId is empty, adds binding with the given name on the global objects of all inspected contexts, including those created later, bindings survive reloads. Binding function takes exactly one argument, this argument should be string, in case of any other input, function throws an exception. Each binding function call produces Runtime.bindingCalled notification. executionContextName If specified, the binding is exposed to the executionContext with matching name, even for contexts created after the binding is added. See also ExecutionContext.name and worldName parameter to Page.addScriptToEvaluateOnNewDocument. This parameter is mutually exclusive with executionContextId.

Implementation

Future<void> addBinding(String name,
    {@Deprecated('This parameter is deprecated')
    ExecutionContextId? executionContextId,
    String? executionContextName}) async {
  await _client.send('Runtime.addBinding', {
    'name': name,
    if (executionContextId != null) 'executionContextId': executionContextId,
    if (executionContextName != null)
      'executionContextName': executionContextName,
  });
}