The DedicatedWorkerGlobalScope object (the Worker global scope) is accessible through the self keyword. Some additional global functions, namespaces objects, and constructors, not typically associated with the worker global scope, but available on it, are listed in the JavaScript Reference. See also: Functions available to workers.

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

See:

Variables

onmessage:Function

Is an EventHandler representing the code to be called when the message event is raised. These events are of type MessageEvent and will be called when the worker receives a message from the document that started it (i.e. from the Worker.postMessage method.)

Methods

postMessage (message:Dynamic, ?transfer:Array<Dynamic>):Void

Throws:

null

DOMError

Inherited Variables

Defined by WorkerGlobalScope

read onlyconsole:Console

Returns the Console associated with the worker.

read onlylocation: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.

read onlynavigator:WorkerNavigator

Returns the WorkerNavigator associated with the worker. It is a specific navigator object, mostly a subset of the Navigator for browsing scopes, but adapted to workers.

onclose:Function

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

onerror:EitherType<Event, String> ‑> String ‑> Int ‑> Int ‑> Dynamic ‑> Bool

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

onoffline:Function

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

ononline:Function

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

read onlyperformance: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.

read onlyself:WorkerGlobalScope

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

Inherited Methods

Defined by WorkerGlobalScope

atob (atob:String):String

Throws:

null

DOMError

btoa (btoa:String):String

Throws:

null

DOMError

clearInterval (handle:Int = 0):Void

clearTimeout (handle:Int = 0):Void

close ():Void

Throws:

null

DOMError

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.

fetch (input:EitherType<Request, String>, ?init:RequestInit):Promise<Response>

Throws:

null

DOMError

importScripts (urls:Rest<String>):Void

Throws:

null

DOMError

setInterval (handler:String, ?timeout:Int, unused:Rest<Dynamic>):Int

setInterval (handler:Function, ?timeout:Int, arguments:Rest<Dynamic>):Int

Throws:

null

DOMError

setTimeout (handler:String, timeout:Int = 0, unused:Rest<Dynamic>):Int

setTimeout (handler:Function, timeout:Int = 0, arguments:Rest<Dynamic>):Int

Throws:

null

DOMError

Defined by EventTarget

addEventListener (type:String, listener:Function, capture:Bool = false):Void

addEventListener (type:String, listener:EventListener, capture:Bool = false, ?wantsUntrusted:Bool):Void

Throws:

null

DOMError

dispatchEvent (event:Event):Bool

Throws:

null

DOMError

removeEventListener (type:String, listener:Function, capture:Bool = false):Void

removeEventListener (type:String, listener:EventListener, capture:Bool = false):Void

Throws:

null

DOMError