Class SharedWorker
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The SharedWorker interface represents a specific kind of worker that can be accessed from several browsing contexts, such as multiple windows or iframes. Shared workers implement a different interface than dedicated workers, have a different global scope (SharedWorkerGlobalScope), and their constructor is not exposed in DedicatedWorkerGlobalScope, so they cannot be instantiated from dedicated workers.
[Value("SharedWorker")]
public class SharedWorker : EventTarget, AbstractWorker
- Inheritance
-
SharedWorker
- Implements
- Inherited Members
Remarks
NOTE
If SharedWorker can be accessed from several browsing contexts, all those browsing contexts must share the exact same origin (same protocol, host and port).
Constructors
SharedWorker()
public SharedWorker()
SharedWorker(Union97, Union98)
WARNING
This script passed to theurlelement is executed.
APIs like this are known as injection sinks, and are potentially a vector for cross-site scripting (XSS) attacks.
public SharedWorker(Union97 scriptURL, Union98 options = default)
Parameters
Remarks
You can mitigate this risk by having a Content Security Policy (CSP) that restricts the locations from which scripts can be loaded, and by always assigning TrustedScriptURL objects instead of strings and enforcing trusted types.
See Security considerations in the Worker() constructor for more information.
The SharedWorker() constructor creates a SharedWorker object that executes the script at the specified URL.
-The SharedWorker interface it belongs to.
Properties
Port
The port property of the SharedWorker
interface returns a MessagePort object used to communicate and control
the shared worker.
[Value("port")]
public MessagePort Port { get; }
Property Value
- MessagePort
A MessagePort object.