Make the devtools loader usable from [Chrome]Workers

NEW
Unassigned

Status

3 years ago
4 months ago

People

(Reporter: fitzgen, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

This is partially done for the worker debugger, but Eddy said it requires special APIs that aren't usually exposed. I don't remember the details.

Eddy, can you expand on what isn't generally available, but would need to be?

I'm tired of using Yet Another Loader: https://developer.mozilla.org/en-US/docs/Mozilla/ChromeWorkers/Chrome_Worker_Modules
Flags: needinfo?(ejpbruel)
(In reply to Nick Fitzgerald [:fitzgen][:nf] from comment #0)
> This is partially done for the worker debugger, but Eddy said it requires
> special APIs that aren't usually exposed. I don't remember the details.
> 
> Eddy, can you expand on what isn't generally available, but would need to be?
> 
> I'm tired of using Yet Another Loader:
> https://developer.mozilla.org/en-US/docs/Mozilla/ChromeWorkers/
> Chrome_Worker_Modules

Specifically, the CommonJS loader needs a way to create sandboxes, and a way to load scripts in those sandboxes. We generally cannot load modules within the same global, because that will lead to unintended side-effects.

For the worker debugger, we provide two functions, createSandbox and loadSubScript, that do exactly this. These functions are defined on WorkerDebuggerGlobalScope, but not on WorkerGlobalScope, so they are not available to client code.

The worker loader is designed to take an API object that implements the above functions, so if you can make these available to chrome workers somehow, you should be able to use the existing worker loaders without problems. This might not be as easy as it sounds, however, since workers were not designed with multiple globals in mind.

Hope that helps!
Flags: needinfo?(ejpbruel)

Updated

4 months ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.