Bug 1540913 - Part 1: allow ModuleLoaders to return BaseURI without ScriptLoader;r=jonco

This is a required change for dynamic import on workers, as the ScriptLoader is not guaranteed to
live long enough. Once the initial script loading is finished, and the script has executed, the
scriptloader is cleared and the strong reference to the workerRef is cleared so that shutdown is
possible. The workerRef is required in order to access the worker private safely. In order to
address this, we move the GetBaseURI method to the module loader itself. In the future, we should
remove the script loader interface all together.

Differential Revision: https://phabricator.services.mozilla.com/D171682
This commit is contained in:
Yulia
2023-03-14 18:16:30 +00:00
parent c7f37da43c
commit 93c966ae8f
4 changed files with 11 additions and 1 deletions

View File

@@ -204,6 +204,8 @@ class ModuleLoaderBase : public nsISupports {
// Called to break cycles during shutdown to prevent memory leaks.
void Shutdown();
virtual nsIURI* GetBaseURI() const { return mLoader->GetBaseURI(); };
using LoadedScript = JS::loader::LoadedScript;
using ScriptFetchOptions = JS::loader::ScriptFetchOptions;
using ScriptLoadRequest = JS::loader::ScriptLoadRequest;