Bug 1781124 - Use static pref for dom.importMaps.enabled in module loader. r=allstarschh

Differential Revision: https://phabricator.services.mozilla.com/D152712
This commit is contained in:
Tooru Fujisawa
2022-07-26 06:30:46 +00:00
parent 751d9edd9b
commit 766ab3e7e8

View File

@@ -24,6 +24,7 @@
#include "mozilla/dom/ScriptLoadContext.h"
#include "mozilla/CycleCollectedJSContext.h" // nsAutoMicroTask
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_dom.h"
#include "nsContentUtils.h"
#include "nsICacheInfoChannel.h" // nsICacheInfoChannel
#include "nsNetUtil.h" // NS_NewURI
@@ -599,14 +600,13 @@ nsresult ModuleLoaderBase::HandleResolveFailure(
ResolveResult ModuleLoaderBase::ResolveModuleSpecifier(
LoadedScript* aScript, const nsAString& aSpecifier) {
bool importMapsEnabled = Preferences::GetBool("dom.importMaps.enabled");
// If import map is enabled, forward to the updated 'Resolve a module
// specifier' algorithm defined in Import maps spec.
//
// Once import map is enabled by default,
// ModuleLoaderBase::ResolveModuleSpecifier should be replaced by
// ImportMap::ResolveModuleSpecifier.
if (importMapsEnabled) {
if (mozilla::StaticPrefs::dom_importMaps_enabled()) {
return ImportMap::ResolveModuleSpecifier(mImportMap.get(), mLoader, aScript,
aSpecifier);
}