GlobalScope Class
A global object (https://html.spec.whatwg.org/multipage/webappapis.html#global-object): a Window, or the global object of a worker (WorkerGlobalScope). It implements the members of the WindowOrWorkerGlobalScope mixin (https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope-mixin), and the parts of its environment settings object the library needs (its event loop, its script engine, the report of the exceptions and of the unhandled promise rejections).
public abstract class GlobalScope : EventTarget- Inheritance
EventTargetGlobalScope
Properties
| Name | Description |
|---|---|
| CrossOriginIsolated | https://html.spec.whatwg.org/multipage/webappapis.html#dom-crossoriginisolated |
| IndexedDB | Gets the entry point of IndexedDB (https://w3c.github.io/IndexedDB/#dom-windoworworkerglobalscope-indexeddb): the databases of the origin, stored by BrowsingContextOptions.IndexedDB. |
| IsSecureContext | https://html.spec.whatwg.org/multipage/webappapis.html#dom-issecurecontext |
| Origin | https://html.spec.whatwg.org/multipage/webappapis.html#dom-origin |
| Performance | https://w3c.github.io/hr-time/#the-performance-attribute |
| Scheduler | Gets the scheduler of the global object (https://wicg.github.io/scheduling-apis/#dom-windoworworkerglobalscope-scheduler), which posts prioritized tasks to its event loop. |
CrossOriginIsolated
https://html.spec.whatwg.org/multipage/webappapis.html#dom-crossoriginisolated
public abstract bool CrossOriginIsolated { get; }Property value
See also
IndexedDB
GlobalScope.csGets the entry point of IndexedDB (https://w3c.github.io/IndexedDB/#dom-windoworworkerglobalscope-indexeddb): the databases of the origin, stored by BrowsingContextOptions.IndexedDB.
public IdbFactory IndexedDB { get; }Property value
See also
IsSecureContext
https://html.spec.whatwg.org/multipage/webappapis.html#dom-issecurecontext
public abstract bool IsSecureContext { get; }Property value
See also
Origin
https://html.spec.whatwg.org/multipage/webappapis.html#dom-origin
public abstract string Origin { get; }Performance
GlobalScope.cshttps://w3c.github.io/hr-time/#the-performance-attribute
public Performance Performance { get; }Property value
See also
Scheduler
GlobalScope.csGets the scheduler of the global object (https://wicg.github.io/scheduling-apis/#dom-windoworworkerglobalscope-scheduler), which posts prioritized tasks to its event loop.
public Scheduler Scheduler { get; }Property value
See also
Methods
| Name | Description |
|---|---|
| Atob(string) | https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob |
| Btoa(string) | https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa |
| ClearInterval(int) | https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-clearinterval |
| ClearTimeout(int) | https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-cleartimeout |
| CreateImageBitmap(object?, ImageBitmapOptions?) | Creates a bitmap from an image source (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-createimagebitmap): an img element, a canvas element, a Blob of an encoded image, an ImageData or another ImageBitmap. The images are decoded by the rendering backend of the browsing context (BrowsingContextOptions.RenderingBackend): without backend, an image or a blob cannot be decoded. |
| CreateImageBitmap(object?, int, int, int, int, ImageBitmapOptions?) | Creates a bitmap from a rectangle of an image source (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-createimagebitmap): see GlobalScope.CreateImageBitmap. The parts of the rectangle outside of the image are transparent black; a negative width or height extends the rectangle to the left or to the top. |
| QueueMicrotask(Action) | https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask |
| ReportError(object?) | https://html.spec.whatwg.org/multipage/webappapis.html#dom-reporterror: reports an exception, as if it was thrown by a script and not caught (an ErrorEvent is fired at the global object). |
| ReportException(ScriptError) | Reports an exception to this global object (https://html.spec.whatwg.org/multipage/webappapis.html#report-an-exception): fires an ErrorEvent at the global object, then, when the event is not canceled (e.g. by onerror returning true), gives the error to BrowsingContextOptions.UnhandledScriptError (the error of a dedicated worker is first propagated to its Worker object). An exception reported while an error is being reported (e.g. thrown by an error event listener) does not fire another event. |
| SetInterval(TimerHandler, int, object?[]) | https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval: runs handler every timeout milliseconds. |
| SetInterval(Action, int) | Runs a .NET callback repeatedly (see GlobalScope.SetInterval). |
| SetTimeout(TimerHandler, int, object?[]) | https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout: runs handler once, from a task, after timeout milliseconds (measured with DomEventLoop.TimeProvider). |
| SetTimeout(Action, int) | Runs a .NET callback once, after a delay (see GlobalScope.SetTimeout). |
| StructuredClone(object?, StructuredSerializeOptions?) | Returns a structured clone of a value (https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone): the value is serialized and deserialized in the realm of the global object by the script engine (without script engine, only the .NET primitive values and the serializable platform objects can be cloned). The objects of the transfer list are transferred (detached) when there is a script engine. |
| TrackPromiseRejection(object, object?, PromiseRejectionOperation) | The HostPromiseRejectionTracker implementation of the HTML Standard (https://html.spec.whatwg.org/multipage/webappapis.html#the-hostpromiserejectiontracker-implementation), called by the script engine when a promise of the realm of the global object is rejected without handler, or when a handler is added to such a promise. The unhandledrejection events are fired after the next microtask checkpoint, and the rejectionhandled events by a task. |
Atob(string)
GlobalScope.cshttps://html.spec.whatwg.org/multipage/webappapis.html#dom-atob
Btoa(string)
GlobalScope.cshttps://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa
ClearInterval(int)
GlobalScope.Timers.cshttps://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-clearinterval
ClearTimeout(int)
GlobalScope.Timers.cshttps://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-cleartimeout
CreateImageBitmap overloads
CreateImageBitmap(object?, ImageBitmapOptions?)
ImageBitmapFactory.csCreates a bitmap from an image source (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-createimagebitmap): an img element, a canvas element, a Blob of an encoded image, an ImageData or another ImageBitmap. The images are decoded by the rendering backend of the browsing context (BrowsingContextOptions.RenderingBackend): without backend, an image or a blob cannot be decoded.
public Task<ImageBitmap> CreateImageBitmap(object? image, ImageBitmapOptions? options = null)Parameters
imageobject?- The image source.
optionsImageBitmapOptions?- The orientation, the scaling and the color options.
Returns
Task<ImageBitmap> A task that completes with the bitmap (in a task of the event loop), or fails with an InvalidStateError when the source cannot be used or decoded.
See also
CreateImageBitmap(object?, int, int, int, int, ImageBitmapOptions?)
ImageBitmapFactory.csCreates a bitmap from a rectangle of an image source (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-createimagebitmap): see GlobalScope.CreateImageBitmap. The parts of the rectangle outside of the image are transparent black; a negative width or height extends the rectangle to the left or to the top.
public Task<ImageBitmap> CreateImageBitmap(object? image, int sx, int sy, int sw, int sh, ImageBitmapOptions? options = null)Parameters
Returns
See also
QueueMicrotask(Action)
GlobalScope.cshttps://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
ReportError(object?)
GlobalScope.cshttps://html.spec.whatwg.org/multipage/webappapis.html#dom-reporterror: reports an exception, as if it was thrown by a script and not caught (an ErrorEvent is fired at the global object).
Parameters
eobject?- The exception: a value of the script engine, or a .NET exception (null is the value undefined).
See also
ReportException(ScriptError)
GlobalScope.csReports an exception to this global object (https://html.spec.whatwg.org/multipage/webappapis.html#report-an-exception): fires an ErrorEvent at the global object, then, when the event is not canceled (e.g. by onerror returning true), gives the error to BrowsingContextOptions.UnhandledScriptError (the error of a dedicated worker is first propagated to its Worker object). An exception reported while an error is being reported (e.g. thrown by an error event listener) does not fire another event.
public bool ReportException(ScriptError error)Parameters
errorScriptError- The information of the exception.
Returns
bool Whether the error was handled: the error event was canceled.
SetInterval overloads
SetInterval(TimerHandler, int, object?[])
GlobalScope.Timers.cshttps://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval: runs handler every timeout milliseconds.
public int SetInterval(TimerHandler handler, int timeout = 0, params object?[] arguments)Parameters
handlerTimerHandler- A callback, or the source text of a script, which only runs when the browsing context has a script engine.
timeoutint- The interval in milliseconds.
argumentsobject?[]- The arguments of the callback.
Returns
int The identifier of the timer, for GlobalScope.ClearInterval.
See also
SetInterval(Action, int)
GlobalScope.Timers.csSetTimeout overloads
SetTimeout(TimerHandler, int, object?[])
GlobalScope.Timers.cshttps://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout: runs handler once, from a task, after timeout milliseconds (measured with DomEventLoop.TimeProvider).
public int SetTimeout(TimerHandler handler, int timeout = 0, params object?[] arguments)Parameters
handlerTimerHandler- A callback, or the source text of a script, which only runs when the browsing context has a script engine.
timeoutint- The delay in milliseconds.
argumentsobject?[]- The arguments of the callback.
Returns
int The identifier of the timer, for GlobalScope.ClearTimeout.
See also
SetTimeout(Action, int)
GlobalScope.Timers.csStructuredClone(object?, StructuredSerializeOptions?)
GlobalScope.csReturns a structured clone of a value (https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone): the value is serialized and deserialized in the realm of the global object by the script engine (without script engine, only the .NET primitive values and the serializable platform objects can be cloned). The objects of the transfer list are transferred (detached) when there is a script engine.
public object? StructuredClone(object? value, StructuredSerializeOptions? options = null)Parameters
valueobject?- The value: a value of the script engine, a .NET primitive value or a serializable platform object, or null for
undefined. optionsStructuredSerializeOptions?- The options: the objects to transfer.
Returns
object? The clone of the value.
Exceptions
DomException- A
DataCloneErrorwhen the value cannot be cloned, or when an object of the transfer list cannot be transferred.
See also
TrackPromiseRejection(object, object?, PromiseRejectionOperation)
GlobalScope.csThe HostPromiseRejectionTracker implementation of the HTML Standard (https://html.spec.whatwg.org/multipage/webappapis.html#the-hostpromiserejectiontracker-implementation), called by the script engine when a promise of the realm of the global object is rejected without handler, or when a handler is added to such a promise. The unhandledrejection events are fired after the next microtask checkpoint, and the rejectionhandled events by a task.
public void TrackPromiseRejection(object promise, object? reason, PromiseRejectionOperation operation)Parameters
promiseobject- The promise.
reasonobject?- The rejection reason of the promise (its [[PromiseResult]]).
operationPromiseRejectionOperation- The operation.