Skip to content

Commit c85b0d2

Browse files
committed
Bug 1720570 - Add ModuleType::CSS; r=allstarschh
Differential Revision: https://phabricator.services.mozilla.com/D263409
1 parent 139007a commit c85b0d2

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

js/public/Modules.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ enum class ModuleType : uint32_t {
4242
Unknown = 0,
4343
JavaScript,
4444
JSON,
45+
CSS,
4546

46-
Limit = JSON,
47+
Limit = CSS,
4748
};
4849

4950
/**

js/src/shell/ModuleLoader.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,12 @@ JSObject* ModuleLoader::loadAndParse(JSContext* cx, HandleString pathArg,
547547
return nullptr;
548548
}
549549
break;
550+
case JS::ModuleType::CSS:
551+
// We don't support CSS modules in the shell because we don't have access to a
552+
// CSS parser in standalone shell builds.
553+
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
554+
JSMSG_BAD_MODULE_TYPE);
555+
return nullptr;
550556
}
551557

552558
if (!addModuleToRegistry(cx, moduleType, path, module)) {

js/src/shell/ShellModuleObjectWrapper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ bool ModuleTypeToString(JSContext* cx, JS::Handle<JSObject*> owner,
365365
case JS::ModuleType::JSON:
366366
to.setString(cx->names().json);
367367
break;
368+
case JS::ModuleType::CSS:
369+
MOZ_ASSERT_UNREACHABLE("CSS modules are not supported in the shell");
370+
break;
368371
}
369372

370373
MOZ_ASSERT(!to.isUndefined());

0 commit comments

Comments
 (0)