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 also:
Variables
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.
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 DedicatedWorkerGlobalScope
, SharedWorkerGlobalScope
or ServiceWorkerGlobalScope
.
Methods
createImageBitmap(aImage:ImageElement, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:VideoElement):Promise<ImageBitmap>
createImageBitmap(aImage:CanvasElement):Promise<ImageBitmap>
createImageBitmap(aImage:Blob):Promise<ImageBitmap>
createImageBitmap(aImage:ImageData):Promise<ImageBitmap>
createImageBitmap(aImage:CanvasRenderingContext2D):Promise<ImageBitmap>
createImageBitmap(aImage:ImageBitmap):Promise<ImageBitmap>
createImageBitmap(aImage:ArrayBufferView):Promise<ImageBitmap>
createImageBitmap(aImage:ArrayBuffer):Promise<ImageBitmap>
createImageBitmap(aImage:VideoElement, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
createImageBitmap(aImage:CanvasElement, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
createImageBitmap(aImage:Blob, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
createImageBitmap(aImage:ImageData, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
createImageBitmap(aImage:CanvasRenderingContext2D, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
createImageBitmap(aImage:ImageBitmap, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
createImageBitmap(aImage:ArrayBufferView, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
createImageBitmap(aImage:ArrayBuffer, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
createImageBitmap(aImage:VideoElement, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:CanvasElement, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:Blob, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:ImageData, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:CanvasRenderingContext2D, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:ImageBitmap, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:ArrayBufferView, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:ArrayBuffer, aOffset:Int, aLength:Int, aFormat:ImageBitmapFormat, aLayout:Array<ChannelPixelLayout>):Promise<ImageBitmap>
createImageBitmap(aImage:ImageElement):Promise<ImageBitmap>
createImageBitmap(aImage:ImageElement, aSx:Int, aSy:Int, aSw:Int, aSh:Int):Promise<ImageBitmap>
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:Request, ?init:Null<RequestInit>):Promise<Response>
fetch(input:String, ?init:Null<RequestInit>):Promise<Response>
importScripts(urls:Rest<String>):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');
Throws:
null | DOMError |
---|