WebIdlRealm<TAdapter, TValue> Class
The realm of a global object (https://html.spec.whatwg.org/multipage/webappapis.html#realms-settings-objects-global-objects): its global object is a window or the global object of a worker, and its interface objects expose the interfaces of the platform that are exposed in the global object. The interface objects of a realm are created on first use.
public sealed class WebIdlRealm<TAdapter, TValue> where TAdapter : struct, IJsAdapter<TValue> where TValue : classType parameters
TAdapter- The adapter of the JavaScript engine.
TValue- The type of the JavaScript values of the engine.
Properties
| Name | Description |
|---|---|
| Adapter | Gets the adapter of the engine. |
| Agent | Gets the bindings of the engine. |
| EngineRealm | Gets the realm of the engine. |
| FunctionPrototype | Gets Function.prototype of the realm. |
| Global | Gets the global object of the realm. |
| GlobalScope | Gets the .NET global object (a window or the global object of a worker), whose JavaScript object is the global object of the realm. |
| ObjectPrototype | Gets Object.prototype of the realm. |
| Window | Gets the window when the global object of the realm is a window, else null. |
Adapter
WebIdlRealm.csGets the adapter of the engine.
public TAdapter Adapter { get; }Property value
TAdapter
Agent
WebIdlRealm.csEngineRealm
WebIdlRealm.csFunctionPrototype
WebIdlRealm.csGets Function.prototype of the realm.
public TValue FunctionPrototype { get; }Property value
TValue
Global
WebIdlRealm.csGets the global object of the realm.
public TValue Global { get; }Property value
TValue
GlobalScope
WebIdlRealm.csGets the .NET global object (a window or the global object of a worker), whose JavaScript object is the global object of the realm.
public GlobalScope GlobalScope { get; }Property value
ObjectPrototype
WebIdlRealm.csGets Object.prototype of the realm.
public TValue ObjectPrototype { get; }Property value
TValue
Window
WebIdlRealm.csMethods
| Name | Description |
|---|---|
| CreateError(string, string) | Creates an error object of this realm (e.g. TypeError). |
| CreateEventHandlerCallback(TValue, bool) | Creates the value of an event handler whose function is function (e.g. a compiled event handler content attribute). |
| CreateRangeError(string) | Returns the exception that throws a RangeError of this realm. |
| CreateTypeError(string) | Returns the exception that throws a TypeError of this realm. |
| Evaluate(string) | Evaluates code in the realm, as an indirect eval. It does not run the pending jobs. |
| FromDate(DateTime?) | Returns the Date object of a date and time; null is a Date object whose time value is NaN (an "Invalid Date"). |
| GetInterfaceObject(string) | Returns the interface object of an interface, creating it in this realm. |
| GetPrototype(string) | Returns the interface prototype object of an interface, creating it in this realm. |
| GetWindowProxy(Window) | Returns the WindowProxy of the browsing context of a window (https://html.spec.whatwg.org/multipage/nav-history-apis.html#windowproxy): one object per browsing context, shared by the realms of the agent, whose [[Window]] is the active window of the browsing context, so that it is the same object before and after a navigation (e.g. the window returned by window.open() and the source of the messages of the documents it navigates to). It is the value of a window for every realm, also the this value of the scripts of the window and the value of globalThis. |
| GetWrapper(object, TValue?) | Returns the JavaScript object of a .NET platform object. |
| Run<TResult>(Func<TResult>) | Runs code with this realm as the current realm, and its global object as the current global object. |
| ToDomString(TValue) | https://webidl.spec.whatwg.org/#js-DOMString |
| ToJs(object?) | Converts a .NET value to a JavaScript value, using its runtime type (for the IDL type any). |
| ToJsError(Exception) | Returns the JavaScript value of a .NET exception thrown by the DOM. |
| ToJsException(Exception) | Converts a .NET exception thrown by the DOM to the JavaScript exception a browser would throw. |
| Unwrap(TValue) | Returns the .NET object of a JavaScript platform object (or the window of a global object), or null. |
CreateError(string, string)
WebIdlRealm.csCreateEventHandlerCallback(TValue, bool)
WebIdlRealm.Callbacks.csCreates the value of an event handler whose function is function (e.g. a compiled event handler content attribute).
public EventHandlerCallback CreateEventHandlerCallback(TValue function, bool isOnBeforeUnloadEventHandler)CreateRangeError(string)
WebIdlRealm.csCreateTypeError(string)
WebIdlRealm.csEvaluate(string)
WebIdlRealm.csFromDate(DateTime?)
WebIdlRealm.csGetInterfaceObject(string)
WebIdlRealm.csGetPrototype(string)
WebIdlRealm.csGetWindowProxy(Window)
WebIdlRealm.WindowProxy.csReturns the WindowProxy of the browsing context of a window (https://html.spec.whatwg.org/multipage/nav-history-apis.html#windowproxy): one object per browsing context, shared by the realms of the agent, whose [[Window]] is the active window of the browsing context, so that it is the same object before and after a navigation (e.g. the window returned by window.open() and the source of the messages of the documents it navigates to). It is the value of a window for every realm, also the this value of the scripts of the window and the value of globalThis.
public TValue GetWindowProxy(Window window)Parameters
windowWindow
Returns
TValue
Remarks
When the window is not same origin-domain with the realm of the caller, the internal methods are the ones of the cross-origin objects (only the cross-origin properties are visible, the others throw a "SecurityError" DOMException). A window that never had a browsing context (e.g. the window of a document created by DOMParser) has no WindowProxy: its global object is returned, as when the engine does not support the WindowProxy objects.
GetWrapper(object, TValue?)
WebIdlRealm.csRun<TResult>(Func<TResult>)
WebIdlRealm.csRuns code with this realm as the current realm, and its global object as the current global object.
public TResult Run<TResult>(Func<TResult> action)