Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update WorkerGlobalScope interface summary #29975

Merged
merged 17 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions files/en-us/web/api/serviceworkerglobalscope/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Listen to this event using {{domxref("EventTarget/addEventListener()", "addEvent
- : Fired when at least one of the requests in a [background fetch](/en-US/docs/Web/API/Background_Fetch_API) operation has failed.
- {{domxref("ServiceWorkerGlobalScope/backgroundfetchsuccess_event", "backgroundfetchsuccess")}} {{Experimental_Inline}}
- : Fired when all of the requests in a [background fetch](/en-US/docs/Web/API/Background_Fetch_API) operation have succeeded.
- {{domxref("ServiceWorkerGlobalScope.canmakepayment_event", "canmakepayment")}} {{Experimental_Inline}}
- {{domxref("ServiceWorkerGlobalScope/canmakepayment_event", "canmakepayment")}} {{Experimental_Inline}}
- : Fired on a payment app's service worker to check whether it is ready to handle a payment. Specifically, it is fired when the merchant website calls {{domxref("PaymentRequest.PaymentRequest", "new PaymentRequest()")}}.
- {{domxref("ServiceWorkerGlobalScope/contentdelete_event", "contentdelete")}} {{Experimental_Inline}}
- : Occurs when an item is removed from the {{domxref("ContentIndex", "Content Index")}}.
Expand All @@ -63,7 +63,7 @@ Listen to this event using {{domxref("EventTarget/addEventListener()", "addEvent
- : Occurs when a user clicks on a displayed notification.
- {{domxref("ServiceWorkerGlobalScope/notificationclose_event", "notificationclose")}}
- : Occurs when a user closes a displayed notification.
- {{domxref("ServiceWorkerGlobalScope.paymentrequest_event", "paymentrequest")}} {{Experimental_Inline}}
- {{domxref("ServiceWorkerGlobalScope/paymentrequest_event", "paymentrequest")}} {{Experimental_Inline}}
- : Fired on a payment app when a payment flow has been initiated on the merchant website via the {{domxref("PaymentRequest.show()")}} method.
- {{domxref("ServiceWorkerGlobalScope/sync_event", "sync")}}
- : Triggered when a call to {{domxref("SyncManager.register")}} is made from a service worker client page. The attempt to sync is made either immediately if the network is available or as soon as the network becomes available.
Expand Down
44 changes: 26 additions & 18 deletions files/en-us/web/api/workerglobalscope/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ _This interface inherits properties from the {{domxref("EventTarget")}} interfac

- {{domxref("caches", "WorkerGlobalScope.caches")}} {{ReadOnlyInline}}
- : Returns the {{domxref("CacheStorage")}} object associated with the current context. This object enables functionality such as storing assets for offline use, and generating custom responses to requests.
- {{domxref("crossOriginIsolated", "WorkerGlobalScope.crossOriginIsolated")}} {{ReadOnlyInline}}
- : Returns a boolean value that indicates whether the website is in a cross-origin isolation state.
- {{domxref("crypto_property", "WorkerGlobalScope.crypto")}} {{ReadOnlyInline}}
- : Returns the {{domxref("Crypto")}} object associated to the global object.
- {{domxref("WorkerGlobalScope.fonts")}} {{ReadOnlyInline}}
- : Returns the {{domxref("FontFaceSet")}} associated with the worker.
- {{domxref("indexedDB", "WorkerGlobalScope.indexedDB")}} {{ReadOnlyInline}}
Expand Down Expand Up @@ -51,25 +55,29 @@ _This interface inherits methods from the {{domxref("EventTarget")}} interface._

### Standard methods

- {{domxref("atob", "WorkerGlobalScope.atob()")}}
- {{domxref("atob()", "WorkerGlobalScope.atob()")}}
- : Decodes a string of data which has been encoded using base-64 encoding.
- {{domxref("btoa", "WorkerGlobalScope.btoa()")}}
- {{domxref("btoa()", "WorkerGlobalScope.btoa()")}}
- : Creates a base-64 encoded {{Glossary("ASCII")}} string from a string of binary data.
- {{domxref("clearInterval", "WorkerGlobalScope.clearInterval()")}}
- {{domxref("clearInterval()", "WorkerGlobalScope.clearInterval()")}}
- : Cancels the repeated execution set using {{domxref("setInterval()")}}.
- {{domxref("clearTimeout", "WorkerGlobalScope.clearTimeout()")}}
- {{domxref("clearTimeout()", "WorkerGlobalScope.clearTimeout()")}}
- : Cancels the delayed execution set using {{domxref("setTimeout()")}}.
- {{domxref("createImageBitmap", "WorkerGlobalScope.createImageBitmap()")}}
- {{domxref("createImageBitmap()", "WorkerGlobalScope.createImageBitmap()")}}
- : Accepts a variety of different image sources, and returns a {{jsxref("Promise")}} which resolves to an {{domxref("ImageBitmap")}}. Optionally the source is cropped to the rectangle of pixels originating at _(sx, sy)_ with width sw, and height sh.
- {{domxref("fetch", "WorkerGlobalScope.fetch()")}}
- {{domxref("fetch()", "WorkerGlobalScope.fetch()")}}
- : Starts the process of fetching a resource from the network.
- {{domxref("WorkerGlobalScope.importScripts()")}}
- : 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');`
- {{domxref("setInterval", "WorkerGlobalScope.setInterval()")}}
- : 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');`.
- {{domxref("queueMicrotask()", "WorkerGlobalScope.queueMicrotask()")}}
- : Queues a microtask to be executed at a safe time prior to control returning to the browser's event loop.
- {{domxref("setInterval()", "WorkerGlobalScope.setInterval()")}}
- : Schedules a function to execute every time a given number of milliseconds elapses.
- {{domxref("setTimeout()", "WorkerGlobalScope.setTimeout()")}}
- : Schedules a function to execute in a given amount of time.
- {{domxref("reportError", "WorkerGlobalScope.reportError()")}}
- {{domxref("structuredClone()", "WorkerGlobalScope.structuredClone()")}}
- : Creates a [deep clone](/en-US/docs/Glossary/Deep_copy) of a given value using the [structured clone algorithm](/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm).
- {{domxref("reportError()", "WorkerGlobalScope.reportError()")}}
- : Reports an error in a script, emulating an unhandled exception.

### Non-standard methods
Expand All @@ -79,18 +87,18 @@ _This interface inherits methods from the {{domxref("EventTarget")}} interface._

## Events

- `error`
- {{domxref("WorkerGlobalScope/error_event", "error")}}
- : Fires when an error occurred.
- `offline`
- {{domxref("WorkerGlobalScope/languagechange_event", "languagechange")}}
- : Fires at the global/worker scope object when the user's preferred languages change.
- {{domxref("WorkerGlobalScope/offline_event", "offline")}}
- : Fires when the browser has lost access to the network and the value of `navigator.onLine` switched to `false`.
- `online`
- {{domxref("WorkerGlobalScope/online_event", "online")}}
- : Fires when the browser has gained access to the network and the value of `navigator.onLine` switched to `true`.
- [`languagechange`](/en-US/docs/Web/API/WorkerGlobalScope/languagechange_event)
- : Fires at the global/worker scope object when the user's preferred languages change.
- `rejectionhandled` {{non-standard_inline}}
- : Fires on handled [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) rejection events.
- `unhandledrejection` {{non-standard_inline}}
- : Fires on unhandled [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) rejection events.
- {{domxref("WorkerGlobalScope/rejectionhandled_event", "rejectionhandled")}}
- : Fires on handled {{jsxref("Promise")}} rejection events.
- {{domxref("WorkerGlobalScope/unhandledrejection_event", "unhandledrejection")}}
- : Fires on unhandled {{jsxref("Promise")}} rejection events.

## Example

Expand Down