зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
7cd2b6b523
Коммит
f37966e2da
|
@ -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)) {
|
||||
|
|
|
@ -271,8 +271,26 @@ JS_PUBLIC_API JSString* JS::GetRequestedModuleSpecifier(
|
|||
CHECK_THREAD(cx);
|
||||
cx->check(moduleRecord);
|
||||
|
||||
auto& module = moduleRecord->as<ModuleObject>();
|
||||
return module.requestedModules()[index].moduleRequest()->specifier();
|
||||
auto* moduleRequest = moduleRecord->as<ModuleObject>()
|
||||
.requestedModules()[index]
|
||||
.moduleRequest();
|
||||
|
||||
// This implements step 7.1.1 in HostLoadImportedModule.
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#hostloadimportedmodule
|
||||
//
|
||||
// If moduleRequest.[[Attributes]] contains a Record entry such that
|
||||
// entry.[[Key]] is not "type",
|
||||
if (moduleRequest->hasFirstUnsupportedAttributeKey()) {
|
||||
UniqueChars printableKey = AtomToPrintableString(
|
||||
cx, moduleRequest->getFirstUnsupportedAttributeKey());
|
||||
JS_ReportErrorNumberASCII(
|
||||
cx, GetErrorMessage, nullptr,
|
||||
JSMSG_IMPORT_ATTRIBUTES_STATIC_IMPORT_UNSUPPORTED_ATTRIBUTE,
|
||||
printableKey ? printableKey.get() : "");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return moduleRequest->specifier();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API void JS::GetRequestedModuleSourcePos(
|
||||
|
|
Загрузка…
Ссылка в новой задаче