Contact emails
Impl: asam...@google.com, nhi...@chromium.org
Explainer / Summary
This feature allows specifying the worker’s name via an optional argument on the constructor. You can distinguish dedicated workers by the name when you have multiple workers with the same URL. Developers can print ‘name’ in dev tools console which will make it easier to debug workers. See discussion at https://github.com/whatwg/html/issues/2477 .
The ‘name’ param in WorkerOptions enables to set worker’s name.
const worker = new Worker(‘worker.js’, { name: ‘worker-name’ });
A worker can access its name by ‘self.name’.
// worker.js
console.log(self.name); // worker_name
When the ‘name’ param is omitted, an empty string is used as the default value.
Spec
‘name’ attribute in WorkerOptions dictionary:
https://html.spec.whatwg.org/multipage/workers.html#workeroptions
‘name’ attribute in DedicatedWorkerGlobalScope interface:
Tag review process is skipped because this feature has already been supported by 2 browsers.
Link to Origin Trial feedback summary
N/A
Is this feature supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
Demo link
N/A
Debuggability
Web developers can display the dedicated worker’s name on their console.
There is a possible DevTools displays dedicated worker’s name in the inspect page in the future.
Risks
Interoperability and Compatibility
Low.
This spec has already been implemented in Firefox and Edge, and not yet in Safari.
There is a web-platform-tests for name property.
Ergonomics
> Are there any other platform APIs this feature will frequently be used in tandem with?
> Could the default usage of this API make it hard for Chrome to maintain good performance (i.e. synchronous return, must run on a certain thread, guaranteed return timing)?
No.
Activation
Easy: Developers just put in name property when they initialize a dedicated worker. Also, they can access it by ‘self.name’.
Is this feature fully tested by web-platform-tests? Link to test suite results from wpt.fyi.
Yes (https://wpt.fyi/results/workers/name-property.html)
Entry on the feature dashboard
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/97c20838-adae-4e7b-9652-1fa79a48fe5c%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CACj%3DBEhA_B%2BzW3MYKngOeLYbibtONxJWbq%2BqUfFsewEwRm2gVg%40mail.gmail.com.