Bug 1918449 - Part 1: Handle unknown module type earlier r=jonco,dom-worker-reviewers,dom-core,asuth,mccr8

We never reach `CompileFetchedModule` if we have an unknown module type since
we take the module type into account when we do mime type checking, so the file
always fails to load because of MIME mismatch, and we don't get the expected
`TypeError.` Checking if we have an unknown type should happen much earlier in
the process.

Differential Revision: https://phabricator.services.mozilla.com/D222222
This commit is contained in:
Jonatan Klemets
2024-09-24 08:50:36 +00:00
parent a82c7c4f64
commit 1ccec98a57
5 changed files with 17 additions and 9 deletions

View File

@@ -204,9 +204,7 @@ nsresult ModuleLoader::CompileFetchedModule(
switch (aRequest->mModuleType) {
case JS::ModuleType::Unknown:
JS_ReportErrorNumberASCII(aCx, js::GetErrorMessage, nullptr,
JSMSG_BAD_MODULE_TYPE);
return NS_ERROR_FAILURE;
MOZ_CRASH("Unexpected module type");
case JS::ModuleType::JavaScript:
return CompileJavaScriptModule(aCx, aOptions, aRequest, aModuleOut);
case JS::ModuleType::JSON: {