Bug 1917899 - Check unsupported import attributes before resolving specifier r=jonco

We need to check if we have an unsupported attribute before resolving the
specifier because, according to the spec, the unknown attribute should be
reported before the invalid specifier.

Differential Revision: https://phabricator.services.mozilla.com/D221998
This commit is contained in:
Jonatan Klemets
2024-09-17 08:25:46 +00:00
parent 074f4c3d10
commit d81453192a
2 changed files with 29 additions and 3 deletions

View File

@@ -839,7 +839,15 @@ nsresult ModuleLoaderBase::ResolveRequestedModules(
for (uint32_t i = 0; i < length; i++) {
JS::Rooted<JSString*> str(
cx, JS::GetRequestedModuleSpecifier(cx, moduleRecord, i));
MOZ_ASSERT(str);
if (!str) {
JS::Rooted<JS::Value> pendingException(cx);
if (!JS_GetPendingException(cx, &pendingException)) {
return NS_ERROR_FAILURE;
}
ms->SetParseError(pendingException);
JS_ClearPendingException(cx);
return NS_ERROR_FAILURE;
}
nsAutoJSString specifier;
if (!specifier.init(cx, str)) {