WorkerGlobalScope

EventTargetjs.html.WorkerGlobalScope (extern class)

The WorkerGlobalScope interface of the Web Workers API is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by Window objects — in this case event handlers, the console or the associated WorkerNavigator object. Each WorkerGlobalScope has its own event loop.

Documentation WorkerGlobalScope by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

Instance Members

Returns a reference to the WorkerGlobalScope itself. Most of the time it is a specific scope like DedicatedWorkerGlobalScopeSharedWorkerGlobalScope or ServiceWorkerGlobalScope.


location: WorkerLocation

Returns the WorkerLocation associated with the worker. It is a specific location object, mostly a subset of the Location for browsing scopes, but adapted to workers.



onoffline: haxe.Function

Is an EventHandler representing the code to be called when the offline event is raised.


ononline: haxe.Function

Is an EventHandler representing the code to be called when the online event is raised.


performance: Performance

Returns the Performance associated with the worker. It is a regular performance object, except that only a subset of its property and methods are available to workers.


crypto: Crypto

origin: String

isSecureContext: Bool



Is an EventHandler representing the code to be called when the error event is raised.

Name Type
`` haxe.extern.EitherType<Event, String>
`` String
`` Int
`` Int
`` Dynamic
Returns
Dynamic

importScripts(urls: haxe.extern.Rest): Void

Imports one or more scripts into the worker's scope. You can specify as many as you'd like, separated by commas. For example: importScripts('foo.js', 'bar.js');

Name Type
urls haxe.extern.Rest

dump(?str: String): Void

Allows you to write a message to stdout — i.e. in your terminal. This is the same as Firefox's window.dump, but for workers.

Name Type Default
str String (optional)

structuredClone(value: structuredClone.T, ?options: AnonStruct): structuredClone.T

Creates a deep clone of a given value using the structured clone algorithm.

Name Type Default
value structuredClone.T
options AnonStruct (optional)
Returns
structuredClone.T

btoa(btoa: String): String
Name Type
btoa String
Returns
String

atob(atob: String): String
Name Type
atob String
Returns
String

setTimeout(handler: String, ?timeout: Int = 0, unused: haxe.extern.Rest): Int
Name Type Default
handler String
timeout Int 0
unused haxe.extern.Rest
Returns
Int

clearTimeout(?handle: Int = 0): Void
Name Type Default
handle Int 0

setInterval(handler: String, ?timeout: Int = 0, unused: haxe.extern.Rest): Int
Name Type Default
handler String
timeout Int 0
unused haxe.extern.Rest
Returns
Int

clearInterval(?handle: Int = 0): Void
Name Type Default
handle Int 0

createImageBitmap(aImage: ImageElement, aOffset: Int, aLength: Int, aFormat: ImageBitmapFormat, aLayout: Array<ChannelPixelLayout>): js.lib.Promise<ImageBitmap>
Name Type
aImage ImageElement
aOffset Int
aLength Int
aFormat ImageBitmapFormat
aLayout Array<ChannelPixelLayout>
Returns
js.lib.Promise<ImageBitmap>

Name Type Default
input Request
init Null<RequestInit> (optional)
Returns
js.lib.Promise<Response>