LibWeb: Always return a KeyAlgorithm from RsaHashedKeyAlgorithm

The spec never mentions the possibility for the `hash` member of
`RsaHashedKeyAlgorithm` to be a string, it should be a `KeyAlgorithm`
object containing a `name` string member.

Spec: https://w3c.github.io/webcrypto/#dfn-RsaHashedKeyAlgorithm
This commit is contained in:
devgianlu 2024-12-26 18:08:37 +01:00 committed by Jelle Raaijmakers
parent 999f456ba4
commit 991cb8942d
Notes: github-actions[bot] 2025-01-17 11:44:02 +00:00
4 changed files with 529 additions and 528 deletions

View file

@ -179,7 +179,10 @@ JS_DEFINE_NATIVE_FUNCTION(RsaHashedKeyAlgorithm::hash_getter)
auto hash = TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->hash(); }));
return hash.visit(
[&](String const& hash_string) -> JS::Value {
return JS::PrimitiveString::create(vm, hash_string);
auto& realm = *vm.current_realm();
auto object = KeyAlgorithm::create(realm);
object->set_name(hash_string);
return object;
},
[&](GC::Root<JS::Object> const& hash) -> JS::Value {
return hash;