Bug 1781124 - Use static pref for dom.importMaps.enabled in module loader. r=allstarschh
authorTooru Fujisawa <arai_a@mac.com>
Tue, 26 Jul 2022 06:30:46 +0000
changeset 625142 f59c0d89e685261ccad544dff452b737acc84b57
parent 625141 e353260f504065dc77ae8fd2f1f46f21925da3c2
child 625143 00746ffaaf58f144db3aa17cad14b27b55388695
push id166795
push userarai_a@mac.com
push dateTue, 26 Jul 2022 07:02:52 +0000
treeherderautoland@f59c0d89e685 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstarschh
bugs1781124
milestone105.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1781124 - Use static pref for dom.importMaps.enabled in module loader. r=allstarschh Differential Revision: https://phabricator.services.mozilla.com/D152712
js/loader/ModuleLoaderBase.cpp
--- a/js/loader/ModuleLoaderBase.cpp
+++ b/js/loader/ModuleLoaderBase.cpp
@@ -19,16 +19,17 @@
 #include "js/OffThreadScriptCompilation.h"
 #include "js/PropertyAndElement.h"  // JS_DefineProperty, JS_GetElement
 #include "js/SourceText.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/dom/AutoEntryScript.h"
 #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
 #include "xpcpublic.h"
 
 using mozilla::Err;
 using mozilla::Preferences;
 using mozilla::UniquePtr;
@@ -594,24 +595,23 @@ nsresult ModuleLoaderBase::HandleResolve
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return NS_OK;
 }
 
 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);
   }
 
   // The following module specifiers are allowed by the spec:
   //  - a valid absolute URL
   //  - a valid relative URL that starts with "/", "./" or "../"
   //