LibWeb: Throw TypeError if WebCrypto algorithm doesn't have "name" field

This commit is contained in:
Andreas Kling 2024-11-24 22:06:59 +01:00 committed by Andreas Kling
commit 7b678d3e1f
Notes: github-actions[bot] 2024-11-24 22:29:24 +00:00
2 changed files with 42 additions and 38 deletions

View file

@ -88,6 +88,10 @@ WebIDL::ExceptionOr<NormalizedAlgorithmAndParameter> normalize_an_algorithm(JS::
// fetch the actual algorithm factory from the registeredAlgorithms map.
auto initial_algorithm = TRY(algorithm.get<GC::Root<JS::Object>>()->get("name"));
if (initial_algorithm.is_undefined()) {
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Algorithm");
}
// 4. Let algName be the value of the name attribute of initialAlg.
auto algorithm_name = TRY(initial_algorithm.to_string(vm));