WorkerGlobalScope Class
The global object of a worker (https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface): a DedicatedWorkerGlobalScope or a SharedWorkerGlobalScope. A worker runs its own event loop on its own thread, and its scripts run in the realm of its own script engine (ScriptEngine.CreateWorkerScriptEngine): the members of a worker global scope must be used on the thread of the worker.
public abstract class WorkerGlobalScope : GlobalScope- Inheritance
GlobalScopeWorkerGlobalScope
Properties
| Name | Description |
|---|---|
| CrossOriginIsolated | https://html.spec.whatwg.org/multipage/webappapis.html#dom-crossoriginisolated: a dedicated worker has the cross-origin isolated capability of its owner (except a worker created from a data: URL); a shared worker is isolated when its embedder policy is compatible with cross-origin isolation (https://html.spec.whatwg.org/multipage/workers.html#run-a-worker). |
| Fonts | The font source of the worker (https://drafts.csswg.org/css-font-loading/#font-source): the font faces created by the scripts of the worker and added to the set, which the text of its OffscreenCanvas objects uses once they are loaded. A worker has no CSS-connected font face. |
| IsSecureContext | https://html.spec.whatwg.org/multipage/webappapis.html#dom-issecurecontext: the creator of the worker is a secure context, and the URL of the worker is potentially trustworthy (or a data: or blob: URL). |
| Location | https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-location |
| Name | Gets the name of the worker (https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-name). |
| Navigator | https://html.spec.whatwg.org/multipage/workers.html#dom-worker-navigator |
| OnError | Gets or sets the event handler of the error event. |
| OnLanguageChange | Gets or sets the event handler of the languagechange event. |
| OnOffline | Gets or sets the event handler of the offline event. |
| OnOnline | Gets or sets the event handler of the online event. |
| OnRejectionHandled | Gets or sets the event handler of the rejectionhandled event. |
| OnUnhandledRejection | Gets or sets the event handler of the unhandledrejection event. |
| Origin | https://html.spec.whatwg.org/multipage/webappapis.html#dom-origin |
| Self | https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-self |
| TrustedTypes | https://w3c.github.io/trusted-types/dist/spec/#dom-windoworworkerglobalscope-trustedtypes: the trusted type policy factory of the worker. Trusted Types are enforced by the require-trusted-types-for and trusted-types directives of the CSP list of the worker (the policies of the response of its script, or the ones of its creator for a worker whose URL is a local scheme). |
CrossOriginIsolated
WorkerGlobalScope.cshttps://html.spec.whatwg.org/multipage/webappapis.html#dom-crossoriginisolated: a dedicated worker has the cross-origin isolated capability of its owner (except a worker created from a data: URL); a shared worker is isolated when its embedder policy is compatible with cross-origin isolation (https://html.spec.whatwg.org/multipage/workers.html#run-a-worker).
public override bool CrossOriginIsolated { get; }Property value
See also
Fonts
WorkerGlobalScope.csThe font source of the worker (https://drafts.csswg.org/css-font-loading/#font-source): the font faces created by the scripts of the worker and added to the set, which the text of its OffscreenCanvas objects uses once they are loaded. A worker has no CSS-connected font face.
public FontFaceSet Fonts { get; }Property value
See also
IsSecureContext
WorkerGlobalScope.cshttps://html.spec.whatwg.org/multipage/webappapis.html#dom-issecurecontext: the creator of the worker is a secure context, and the URL of the worker is potentially trustworthy (or a data: or blob: URL).
public override bool IsSecureContext { get; }Property value
See also
Location
WorkerGlobalScope.cshttps://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-location
public WorkerLocation Location { get; }OnError
WorkerGlobalScope.csGets or sets the event handler of the error event.
OnLanguageChange
WorkerGlobalScope.csGets or sets the event handler of the languagechange event.
OnOffline
WorkerGlobalScope.csGets or sets the event handler of the offline event.
OnOnline
WorkerGlobalScope.csGets or sets the event handler of the online event.
OnRejectionHandled
WorkerGlobalScope.csGets or sets the event handler of the rejectionhandled event.
OnUnhandledRejection
WorkerGlobalScope.csGets or sets the event handler of the unhandledrejection event.
Origin
WorkerGlobalScope.cshttps://html.spec.whatwg.org/multipage/webappapis.html#dom-origin
public override string Origin { get; }https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-self
public WorkerGlobalScope Self { get; }TrustedTypes
TrustedTypesGlobals.cshttps://w3c.github.io/trusted-types/dist/spec/#dom-windoworworkerglobalscope-trustedtypes: the trusted type policy factory of the worker. Trusted Types are enforced by the require-trusted-types-for and trusted-types directives of the CSP list of the worker (the policies of the response of its script, or the ones of its creator for a worker whose URL is a local scheme).
public TrustedTypePolicyFactory TrustedTypes { get; }Methods
| Name | Description |
|---|---|
| ImportScripts(IEnumerable<object>) | Runs the scripts of urls synchronously, in order, in the realm of the worker (https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts). |
| ImportScripts(string[]) | Runs the scripts of urls synchronously, in order, in the realm of the worker (https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts). The exceptions of the scripts are rethrown; a script that cannot be fetched throws a NetworkError. |
ImportScripts overloads
ImportScripts(IEnumerable<object>)
WorkerGlobalScope.csRuns the scripts of urls synchronously, in order, in the realm of the worker (https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts).
public void ImportScripts(IEnumerable<object> urls)Parameters
urlsIEnumerable<object>- The URLs of the scripts (strings or
TrustedScriptUrlobjects), relative to the URL of the worker.
See also
ImportScripts(string[])
WorkerGlobalScope.csRuns the scripts of urls synchronously, in order, in the realm of the worker (https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts). The exceptions of the scripts are rethrown; a script that cannot be fetched throws a NetworkError.
Parameters
urlsstring[]- The URLs of the scripts, relative to the URL of the worker.
Exceptions
TypeErrorException- The worker is a module worker.
DomException- A
SyntaxErrorwhen a URL is invalid, or aNetworkErrorwhen a script cannot be fetched.