WebIdlAgent<TAdapter, TValue> Class

The WebIDL bindings of the DOM for a JavaScript engine (an agent: the similar-origin window agent, or the agent of a worker): the realms of the global objects, and the JavaScript objects of the .NET objects. A platform object has a single JavaScript object, whichever realm accesses it, so the wrappers and the callbacks are shared by the realms.

public sealed class WebIdlAgent<TAdapter, TValue> where TAdapter : struct, IJsAdapter<TValue> where TValue : class

Type parameters

TAdapter
The adapter of the JavaScript engine.
TValue
The type of the JavaScript values of the engine.

Constructors

NameDescription
WebIdlAgent(TAdapter, IWebIdlHost)Creates the bindings of an engine.

WebIdlAgent(TAdapter, IWebIdlHost)

WebIdlAgent.cs

Creates the bindings of an engine.

public WebIdlAgent(TAdapter adapter, IWebIdlHost host)

Parameters

adapter TAdapter
The adapter of the engine.
host IWebIdlHost
The services of the script engine.

Properties

NameDescription
AdapterGets the adapter of the engine.
CurrentRealmGets the realm of the running execution context, or null when it is not the realm of a global object.
HostGets the services of the script engine.
RealmCreatedGets or sets a callback invoked when a realm is created, before any script runs in it: the host can add its own functions to the global object.
RealmFactoryGets or sets a factory of the realms of the engine. The first realm uses the realm that is current when the agent is created; the default factory of the other realms throws NotSupportedException.
RealmsGets the realms.

Gets the adapter of the engine.

public TAdapter Adapter { get; }

Property value

TAdapter

CurrentRealm

WebIdlAgent.cs

Gets the realm of the running execution context, or null when it is not the realm of a global object.

public WebIdlRealm<TAdapter, TValue>? CurrentRealm { get; }

Gets the services of the script engine.

public IWebIdlHost Host { get; }

Property value

IWebIdlHost

RealmCreated

WebIdlAgent.cs

Gets or sets a callback invoked when a realm is created, before any script runs in it: the host can add its own functions to the global object.

public Action<WebIdlRealm<TAdapter, TValue>>? RealmCreated { get; set; }

RealmFactory

WebIdlAgent.cs

Gets or sets a factory of the realms of the engine. The first realm uses the realm that is current when the agent is created; the default factory of the other realms throws NotSupportedException.

public Func<object>? RealmFactory { get; set; }

Property value

Func<object>?

Gets the realms.

public IEnumerable<WebIdlRealm<TAdapter, TValue>> Realms { get; }

Methods

NameDescription
DisposeWebAssembly()Releases the WebAssembly store of the agent (the native resources of the runtime).
GetAssociatedRealm(TValue)Returns the associated realm of a callback (https://webidl.spec.whatwg.org/#dfn-associated-realm): the realm whose Function.prototype (for a function) or Object.prototype is in the prototype chain of the object. The prototype chain of a revoked proxy cannot be read: its associated realm is the realm that created it.
GetExceptionValue(Exception, WebIdlRealm<TAdapter, TValue>)Returns the JavaScript value of an exception thrown by the engine or by the DOM, in the current realm.
GetRealm(GlobalScope)Returns the realm of a global object, creating it on first use.
GetRealm(object)Returns the realm of an engine realm, or null.
GetRealmByGlobal(TValue)Returns the realm whose global object is global, or null.
TryGetRealm(GlobalScope)Returns the realm of a global object, or null when it was not created.

DisposeWebAssembly()

WebIdlAgent.cs

Releases the WebAssembly store of the agent (the native resources of the runtime).

public void DisposeWebAssembly()

GetAssociatedRealm(TValue)

WebIdlAgent.cs

Returns the associated realm of a callback (https://webidl.spec.whatwg.org/#dfn-associated-realm): the realm whose Function.prototype (for a function) or Object.prototype is in the prototype chain of the object. The prototype chain of a revoked proxy cannot be read: its associated realm is the realm that created it.

public WebIdlRealm<TAdapter, TValue>? GetAssociatedRealm(TValue obj)

Parameters

obj TValue

Returns

WebIdlRealm<TAdapter, TValue>?

GetExceptionValue(Exception, WebIdlRealm<TAdapter, TValue>)

WebIdlAgent.cs

Returns the JavaScript value of an exception thrown by the engine or by the DOM, in the current realm.

public TValue GetExceptionValue(Exception exception, WebIdlRealm<TAdapter, TValue> fallbackRealm)

Parameters

exception Exception
fallbackRealm WebIdlRealm<TAdapter, TValue>

Returns

TValue

GetRealm overloads

GetRealm(GlobalScope)

WebIdlAgent.cs

Returns the realm of a global object, creating it on first use.

public WebIdlRealm<TAdapter, TValue> GetRealm(GlobalScope global)

GetRealm(object)

WebIdlAgent.cs

Returns the realm of an engine realm, or null.

public WebIdlRealm<TAdapter, TValue>? GetRealm(object engineRealm)
Parameters
engineRealm object
Returns

WebIdlRealm<TAdapter, TValue>?

GetRealmByGlobal(TValue)

WebIdlAgent.cs

Returns the realm whose global object is global, or null.

public WebIdlRealm<TAdapter, TValue>? GetRealmByGlobal(TValue global)

Parameters

global TValue

Returns

WebIdlRealm<TAdapter, TValue>?

TryGetRealm(GlobalScope)

WebIdlAgent.cs

Returns the realm of a global object, or null when it was not created.

public WebIdlRealm<TAdapter, TValue>? TryGetRealm(GlobalScope global)