Bug 1803984 - Part 1: Don't use the preloaded module request if there's an import map. r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D178298
This commit is contained in:
Yoshi Cheng-Hao Huang 2023-06-28 08:43:42 +00:00
Родитель 4c07252d96
Коммит 53e105ef77
3 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -983,6 +983,17 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
return false;
}
// If there are a preloaded request and an import map, we won't use the
// preloaded request and will try to create a new one for this, because the
// import map isn't preloaded, and the preloaded request may have used the
// wrong module specifiers.
if (request && request->IsModuleRequest() &&
mModuleLoader->HasImportMapRegistered()) {
DebugOnly<bool> removed = mModuleLoader->RemoveFetchedModule(request->mURI);
MOZ_ASSERT(removed);
request = nullptr;
}
if (request) {
// Use the preload request.

Просмотреть файл

@ -453,6 +453,11 @@ nsresult ModuleLoaderBase::GetFetchedModuleURLs(nsTArray<nsCString>& aURLs) {
return NS_OK;
}
bool ModuleLoaderBase::RemoveFetchedModule(nsIURI* aURL) {
MOZ_ASSERT(IsModuleFetched(aURL));
return mFetchedModules.Remove(aURL);
}
void ModuleLoaderBase::SetModuleFetchStarted(ModuleLoadRequest* aRequest) {
// Update the module map to indicate that a module is currently being fetched.

Просмотреть файл

@ -314,6 +314,8 @@ class ModuleLoaderBase : public nsISupports {
nsresult GetFetchedModuleURLs(nsTArray<nsCString>& aURLs);
bool RemoveFetchedModule(nsIURI* aURL);
// Internal methods.
private: