Interface IJavaScriptEngine
Defines an interface allowing the user to manage settings in the browser's JavaScript engine.
public interface IJavaScriptEngine : IDisposable
- Inherited Members
Properties
InitializationScripts
Gets the read-only list of initialization scripts added for this JavaScript engine.
IReadOnlyList<InitializationScript> InitializationScripts { get; }
Property Value
ScriptCallbackBindings
Gets the read-only list of binding callbacks added for this JavaScript engine.
IReadOnlyList<string> ScriptCallbackBindings { get; }
Property Value
Methods
AddInitializationScript(string, string)
Asynchronously adds JavaScript to be loaded on every document load.
Task<InitializationScript> AddInitializationScript(string scriptName, string script)
Parameters
scriptNamestringThe friendly name by which to refer to this initialization script.
scriptstringThe JavaScript to be loaded on every page.
Returns
- Task<InitializationScript>
A task containing an InitializationScript object representing the script to be loaded on each page.
Exceptions
- ArgumentNullException
If
scriptNameorscriptare null.
AddScriptCallbackBinding(string)
Asynchronously adds a binding to a callback method that will raise an event when the named binding is called by JavaScript executing in the browser.
Task AddScriptCallbackBinding(string bindingName)
Parameters
bindingNamestringThe name of the callback that will trigger events when called by JavaScript executing in the browser.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
If
bindingNameis null.- ArgumentException
If A binding with the specified name already exists.
ClearAll()
Asynchronously removes all bindings to JavaScript callbacks and all initialization scripts from being loaded for each document.
Task ClearAll()
Returns
- Task
A task that represents the asynchronous operation.
ClearInitializationScripts()
Asynchronously removes all initialization scripts from being loaded on every document load.
Task ClearInitializationScripts()
Returns
- Task
A task that represents the asynchronous operation.
ClearScriptCallbackBindings()
Asynchronously removes all bindings to JavaScript callbacks.
Task ClearScriptCallbackBindings()
Returns
- Task
A task that represents the asynchronous operation.
DisableDomMutationMonitoring()
Disables monitoring for DOM changes.
Task DisableDomMutationMonitoring()
Returns
- Task
A task that represents the asynchronous operation.
EnableDomMutationMonitoring()
Enables monitoring for DOM changes.
Task EnableDomMutationMonitoring()
Returns
- Task
A task that represents the asynchronous operation.
PinScript(string)
Pins a JavaScript snippet for execution in the browser without transmitting the entire script across the wire for every execution.
Task<PinnedScript> PinScript(string script)
Parameters
scriptstringThe JavaScript to pin
Returns
- Task<PinnedScript>
A task containing a PinnedScript object to use to execute the script.
Exceptions
- ArgumentNullException
If
scriptis null.
RemoveInitializationScript(string)
Asynchronously removes JavaScript from being loaded on every document load.
Task RemoveInitializationScript(string scriptName)
Parameters
scriptNamestringThe friendly name of the initialization script to be removed.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
If
scriptNameis null.
RemoveScriptCallbackBinding(string)
Asynchronously removes a binding to a JavaScript callback.
Task RemoveScriptCallbackBinding(string bindingName)
Parameters
bindingNamestringThe name of the callback to be removed.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
If
bindingNameis null.
Reset()
Asynchronously removes all bindings to JavaScript callbacks, all initialization scripts from being loaded for each document, and stops listening for events.
Task Reset()
Returns
- Task
A task that represents the asynchronous operation.
StartEventMonitoring()
Asynchronously starts monitoring for events from the browser's JavaScript engine.
Task StartEventMonitoring()
Returns
- Task
A task that represents the asynchronous operation.
StopEventMonitoring()
Stops monitoring for events from the browser's JavaScript engine.
void StopEventMonitoring()
UnpinScript(PinnedScript)
Unpins a previously pinned script from the browser.
Task UnpinScript(PinnedScript script)
Parameters
scriptPinnedScriptThe PinnedScript object to unpin.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
If
scriptis null.
Events
DomMutated
Occurs when a value of an attribute in an element is being changed.
event EventHandler<DomMutatedEventArgs>? DomMutated
Event Type
JavaScriptCallbackExecuted
Occurs when a JavaScript callback with a named binding is executed.
event EventHandler<JavaScriptCallbackExecutedEventArgs>? JavaScriptCallbackExecuted
Event Type
JavaScriptConsoleApiCalled
Occurs when methods on the JavaScript console are called.
event EventHandler<JavaScriptConsoleApiCalledEventArgs>? JavaScriptConsoleApiCalled
Event Type
JavaScriptExceptionThrown
Occurs when an exception is thrown by JavaScript being executed in the browser.
event EventHandler<JavaScriptExceptionThrownEventArgs>? JavaScriptExceptionThrown