addScriptToEvaluateOnNewDocument method
Evaluates given script in every frame upon creation (before loading frame's scripts).
worldName
If specified, creates an isolated world with the given name and evaluates given script in it.
This world name will be used as the ExecutionContextDescription::name when the corresponding
event is emitted.
includeCommandLineAPI
Specifies whether command line API should be available to the script, defaults
to false.
Returns: Identifier of the added script.
Implementation
Future<ScriptIdentifier> addScriptToEvaluateOnNewDocument(String source,
{String? worldName, bool? includeCommandLineAPI}) async {
var result = await _client.send('Page.addScriptToEvaluateOnNewDocument', {
'source': source,
if (worldName != null) 'worldName': worldName,
if (includeCommandLineAPI != null)
'includeCommandLineAPI': includeCommandLineAPI,
});
return ScriptIdentifier.fromJson(result['identifier'] as String);
}