Skip to content

Commit bec9f73

Browse files
committed
Bug 1720570 - Move ModuleTypeAllowed check into ModuleLoaderBase; r=allstarschh
CSS Modules are not supported in Workers and Worklets. This adds a IsModuleTypeAllowed to ModuleLoaderBase so that the subclasses can decide which modules are allowed. Differential Revision: https://phabricator.services.mozilla.com/D263412
1 parent 4ea2f77 commit bec9f73

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

js/loader/ModuleLoaderBase.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ void ModuleLoaderBase::EnsureModuleHooksInitialized() {
101101
HostReleaseTopLevelScript);
102102
}
103103

104-
static bool ModuleTypeAllowed(ModuleType aModuleType) {
105-
return aModuleType != ModuleType::Unknown;
106-
}
107-
108104
static bool CreateBadModuleTypeError(JSContext* aCx, LoadedScript* aScript,
109105
nsIURI* aURI,
110106
MutableHandle<Value> aErrorOut) {
@@ -219,7 +215,7 @@ bool ModuleLoaderBase::HostLoadImportedModule(JSContext* aCx,
219215
MOZ_ASSERT(uri, "Failed to resolve module specifier");
220216

221217
ModuleType moduleType = GetModuleRequestType(aCx, aModuleRequest);
222-
if (!ModuleTypeAllowed(moduleType)) {
218+
if (!loader->IsModuleTypeAllowed(moduleType)) {
223219
LOG(("ModuleLoaderBase::HostLoadImportedModule uri %s, bad module type",
224220
uri->GetSpecOrDefault().get()));
225221
Rooted<Value> error(aCx);

js/loader/ModuleLoaderBase.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ class ModuleLoaderBase : public nsISupports {
421421
// https://html.spec.whatwg.org/multipage/webappapis.html#disallow-further-import-maps
422422
void DisallowImportMaps() { mImportMapsAllowed = false; }
423423

424+
virtual bool IsModuleTypeAllowed(ModuleType aModuleType) {
425+
return aModuleType != ModuleType::Unknown;
426+
}
427+
424428
// Returns whether there has been an entry in the import map
425429
// for the given aURI.
426430
bool GetImportMapSRI(nsIURI* aURI, nsIURI* aSourceURI,

0 commit comments

Comments
 (0)