Issue #1691 - Part 16: Dynamically imported modules can throw any value as an exception. https://bugzilla.mozilla.org/show_bug.cgi?id=1508672

(cherry picked from commit 910a37b53f1826a863cc3ab6eb61fc369f4505a0)
This commit is contained in:
Brian Smith 2023-04-24 17:31:39 -05:00 committed by roytam1
commit 1ac1e90b6a

View file

@ -4266,16 +4266,10 @@ AbortDynamicModuleImport(JSContext* cx, unsigned argc, Value* vp)
return ReportArgumentTypeError(cx, args[2], "PromiseObject");
}
if (!args[3].isObject() || !args[3].toObject().is<ErrorObject>()) {
return ReportArgumentTypeError(cx, args[3], "ErrorObject");
}
RootedString specifier(cx, args[1].toString());
Rooted<PromiseObject*> promise(cx, &args[2].toObject().as<PromiseObject>());
Rooted<ErrorObject*> error(cx, &args[3].toObject().as<ErrorObject>());
Rooted<Value> value(cx, ObjectValue(*error));
cx->setPendingException(value);
cx->setPendingException(args[3]);
return js::FinishDynamicModuleImport(cx, args[0], specifier, promise);
}