Skip to content

WorkerGlobalScope

Generated from idl/workers.webidl when the site was built at 7aa23e2.

WorkerGlobalScope is an interface in idl/workers.webidl, inheriting EventTarget, exposed in Worker. It includes WindowOrWorkerGlobalScope. What it does is on MDN; this page says what niso has of it.

The web features its members belong to, each with its Baseline status on the web and how much of the feature’s WPT suite passes in niso (see Web platform support).

Feature On the web In niso Members
Dedicated workers Widely available Partial 85% 410 of 477 subtests pass 6
Online status Widely available Not yet 0 of 3 subtests pass 2
Language Widely available Full 2 of 2 subtests pass 1
attribute
readonly attribute WorkerGlobalScope self;
int32_t niso_worker_global_scope_get_self(niso_dom* dom, niso_handle self, niso_handle* out);
attribute
readonly attribute WorkerLocation location;
int32_t niso_worker_global_scope_get_location(niso_dom* dom, niso_handle self, niso_handle* out);
attribute
attribute EventHandler onerror;
int32_t niso_worker_global_scope_get_onerror(niso_dom* dom, niso_handle self, void** out);
int32_t niso_worker_global_scope_set_onerror(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);

OnErrorEventHandler: the binding calls the handler with the ErrorEvent’s message, filename, lineno, colno and error.

attribute Language: Full
attribute EventHandler onlanguagechange;
int32_t niso_worker_global_scope_get_onlanguagechange(niso_dom* dom, niso_handle self, void** out);
int32_t niso_worker_global_scope_set_onlanguagechange(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
attribute Online status: Not yet
attribute EventHandler onoffline;
int32_t niso_worker_global_scope_get_onoffline(niso_dom* dom, niso_handle self, void** out);
int32_t niso_worker_global_scope_set_onoffline(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
attribute Online status: Not yet
attribute EventHandler ononline;
int32_t niso_worker_global_scope_get_ononline(niso_dom* dom, niso_handle self, void** out);
int32_t niso_worker_global_scope_set_ononline(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
attribute
attribute EventHandler onrejectionhandled;
int32_t niso_worker_global_scope_get_onrejectionhandled(niso_dom* dom, niso_handle self, void** out);
int32_t niso_worker_global_scope_set_onrejectionhandled(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
attribute
attribute EventHandler onunhandledrejection;
int32_t niso_worker_global_scope_get_onunhandledrejection(niso_dom* dom, niso_handle self, void** out);
int32_t niso_worker_global_scope_set_onunhandledrejection(niso_dom* dom, niso_handle self, niso_event_handler_non_null_fn value_fn, void* value_userdata, niso_drop_fn value_drop);
operation not in JS
[NisoInternal, NisoReentrant] undefined report(DOMString message, USVString filename, unsigned long lineno, unsigned long colno, [NisoHeld] any error);
int32_t niso_worker_global_scope_report(niso_dom* dom, niso_handle self, const char* message, size_t message_len, const char* filename, size_t filename_len, uint32_t lineno, uint32_t colno, niso_held error);

HTML’s “report an exception” for an uncaught exception with these details: fires an ErrorEvent at the global, and when it was not canceled, the error goes on to the Worker object in the parent.

operation from WindowOrWorkerGlobalScope
[NisoGlue] Promise<ImageBitmap> createImageBitmap(any image, optional any a, optional any b, optional any c, optional any d, optional any e);
operation not in JS from WindowOrWorkerGlobalScope
[NisoInternal] ImageBitmap bitmapFrom(Element? element, ImageBitmap? bitmap, OffscreenCanvas? offscreen, Uint8ClampedArray data, unsigned long width, unsigned long height, boolean crop, long sx, long sy, long sw, long sh);
int32_t niso_window_or_worker_global_scope_bitmap_from(niso_dom* dom, niso_handle self, niso_handle element, niso_handle bitmap, niso_handle offscreen, const uint8_t* data, size_t data_len, uint32_t width, uint32_t height, bool crop, int32_t sx, int32_t sy, int32_t sw, int32_t sh, niso_handle* out);

One of element, bitmap and offscreen is the image, or data (width by height straight RGBA) when all three are null; cropped to sx, sy, sw, sh when crop is set.

operation not in JS from WindowOrWorkerGlobalScope
[NisoInternal] ImageBitmap? bitmapDecode(ArrayBuffer bytes);
int32_t niso_window_or_worker_global_scope_bitmap_decode(niso_dom* dom, niso_handle self, const uint8_t* bytes, size_t bytes_len, niso_handle* out);

An image file’s bytes decoded.

attribute from WindowOrWorkerGlobalScope
readonly attribute USVString origin;
int32_t niso_window_or_worker_global_scope_get_origin(niso_dom* dom, niso_handle self, niso_str* out);

The standard’s is [Replaceable], which the generator does not support.

operation from WindowOrWorkerGlobalScope
long setTimeout(TimerHandler handler, optional long timeout = 0);
int32_t niso_window_or_worker_global_scope_set_timeout(niso_dom* dom, niso_handle self, niso_timer_handler_fn handler_fn, void* handler_userdata, niso_drop_fn handler_drop, int32_t timeout, int32_t* out);
operation from WindowOrWorkerGlobalScope
undefined clearTimeout(optional long id = 0);
int32_t niso_window_or_worker_global_scope_clear_timeout(niso_dom* dom, niso_handle self, int32_t id);
operation from WindowOrWorkerGlobalScope
long setInterval(TimerHandler handler, optional long timeout = 0);
int32_t niso_window_or_worker_global_scope_set_interval(niso_dom* dom, niso_handle self, niso_timer_handler_fn handler_fn, void* handler_userdata, niso_drop_fn handler_drop, int32_t timeout, int32_t* out);
operation from WindowOrWorkerGlobalScope
undefined clearInterval(optional long id = 0);
int32_t niso_window_or_worker_global_scope_clear_interval(niso_dom* dom, niso_handle self, int32_t id);
operation not in JS from WindowOrWorkerGlobalScope
[NisoInternal] undefined queueTask(VoidFunction callback);
int32_t niso_window_or_worker_global_scope_queue_task(niso_dom* dom, niso_handle self, niso_void_function_fn callback_fn, void* callback_userdata, niso_drop_fn callback_drop);

Queues a task on the DOM’s task queue that calls callback: HTML’s “queue a global task”, for the binding’s own algorithms (postMessage, script events), which run in Dom::run like the DOM’s own tasks.

attribute from WindowOrWorkerGlobalScope
[SameObject] readonly attribute IDBFactory indexedDB;
int32_t niso_window_or_worker_global_scope_get_indexed_db(niso_dom* dom, niso_handle self, niso_handle* out);
attribute from WindowOrWorkerGlobalScope
readonly attribute Performance performance;
int32_t niso_window_or_worker_global_scope_get_performance(niso_dom* dom, niso_handle self, niso_handle* out);
attribute from WindowOrWorkerGlobalScope
[SameObject] readonly attribute Crypto crypto;
int32_t niso_window_or_worker_global_scope_get_crypto(niso_dom* dom, niso_handle self, niso_handle* out);

Members the web has, by the BCD keys web-features 3.45.0 lists, that idl/ doesn’t declare. The list is partial: web-features lists only the keys it maps to a feature.

  • fonts (Font loading)
  • importScripts (Dedicated workers)
  • navigator (Dedicated workers)
  • securitypolicyviolation event (Content Security Policy (CSP))