mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibWeb: Make factory method of Crypto::SubtleCrypto fallible
This commit is contained in:
parent
58af8e2021
commit
52e9839d8b
3 changed files with 8 additions and 5 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <AK/Random.h>
|
#include <AK/Random.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
|
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Crypto/Crypto.h>
|
#include <LibWeb/Crypto/Crypto.h>
|
||||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||||
|
@ -30,7 +31,9 @@ JS::ThrowCompletionOr<void> Crypto::initialize(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CryptoPrototype>(realm, "Crypto"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CryptoPrototype>(realm, "Crypto"));
|
||||||
m_subtle = SubtleCrypto::create(realm);
|
m_subtle = TRY(Bindings::throw_dom_exception_if_needed(realm.vm(), [&]() {
|
||||||
|
return SubtleCrypto::create(realm);
|
||||||
|
}));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||||
#include <LibWeb/WebIDL/DOMException.h>
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||||
|
|
||||||
namespace Web::Crypto {
|
namespace Web::Crypto {
|
||||||
|
|
||||||
JS::NonnullGCPtr<SubtleCrypto> SubtleCrypto::create(JS::Realm& realm)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<SubtleCrypto>> SubtleCrypto::create(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
return realm.heap().allocate<SubtleCrypto>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
return MUST_OR_THROW_OOM(realm.heap().allocate<SubtleCrypto>(realm, realm));
|
||||||
}
|
}
|
||||||
|
|
||||||
SubtleCrypto::SubtleCrypto(JS::Realm& realm)
|
SubtleCrypto::SubtleCrypto(JS::Realm& realm)
|
||||||
|
|
|
@ -15,7 +15,7 @@ class SubtleCrypto final : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(SubtleCrypto, Bindings::PlatformObject);
|
WEB_PLATFORM_OBJECT(SubtleCrypto, Bindings::PlatformObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static JS::NonnullGCPtr<SubtleCrypto> create(JS::Realm&);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<SubtleCrypto>> create(JS::Realm&);
|
||||||
|
|
||||||
virtual ~SubtleCrypto() override;
|
virtual ~SubtleCrypto() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue