Closed Bug 1433788 Opened 6 years ago Closed 6 years ago

When are Shared Workers shared?

Categories

(Core :: DOM: Workers, enhancement)

x86_64
Linux
enhancement
Not set
minor

Tracking

()

RESOLVED DUPLICATE of bug 1224904
Tracking Status
firefox60 --- affected

People

(Reporter: pipcet, Unassigned)

References

()

Details

I don't understand when SharedWorker()s are shared. If I open https://antigone2.github.io/sharedWorkers/ in two tabs, copy-and-pasting the URL, I get two shared workers in about:debugging, and they're not synchronized (stopping the counter in one tab doesn't affect the other tab). If I set dom.ipc.multiOptOut, there's just one worker, and things are synchronized. If I use the link on the page to create another tab, things are synchronized even without the multiOptOut setting.

This isn't necessarily a bug, but it is surprising and apparently undocumented behavior: I expected shared workers to be shared when they're created in non-Private-Browsing context with the same URL. Since SharedWorkers can communicate anyhow, there doesn't appear to be a security reason for our current behavior.

Can we document our current behavior, if it is intentional, or change it otherwise?
See bug 1224904.  With multiple content processes we don't properly share the worker when windows are in different processes.

Depending on what you are trying to do you may be able to use BroadcastChannel instead.  That will send a postMessage() to all same-origin listeners in any process.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.