mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibWeb: Expose crypto
object to workers
This change moves the `crypto()` getter from `Window` to `WorkerOrWindowGlobalScope`. This aligns our implementation with the WebCrypto specification.
This commit is contained in:
parent
d6a31d80c0
commit
89b6cd3fb1
Notes:
github-actions[bot]
2024-09-18 08:09:56 +00:00
Author: https://github.com/tcl3
Commit: 89b6cd3fb1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1419
9 changed files with 33 additions and 19 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Crypto/Crypto.h>
|
||||
#include <LibWeb/Fetch/FetchMethod.h>
|
||||
#include <LibWeb/HTML/CanvasRenderingContext2D.h>
|
||||
#include <LibWeb/HTML/ErrorEvent.h>
|
||||
|
@ -72,6 +73,7 @@ void WindowOrWorkerGlobalScopeMixin::visit_edges(JS::Cell::Visitor& visitor)
|
|||
for (auto& entry : m_performance_entry_buffer_map)
|
||||
entry.value.visit_edges(visitor);
|
||||
visitor.visit(m_registered_event_sources);
|
||||
visitor.visit(m_crypto);
|
||||
}
|
||||
|
||||
void WindowOrWorkerGlobalScopeMixin::finalize()
|
||||
|
@ -838,4 +840,15 @@ void WindowOrWorkerGlobalScopeMixin::report_error(JS::Value e)
|
|||
}
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webcrypto/#dom-windoworworkerglobalscope-crypto
|
||||
JS::NonnullGCPtr<Crypto::Crypto> WindowOrWorkerGlobalScopeMixin::crypto()
|
||||
{
|
||||
auto& platform_object = this_impl();
|
||||
auto& realm = platform_object.realm();
|
||||
|
||||
if (!m_crypto)
|
||||
m_crypto = platform_object.heap().allocate<Crypto::Crypto>(realm, realm);
|
||||
return JS::NonnullGCPtr { *m_crypto };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue