diff --git a/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp b/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp index 297ef68886c..abdbe1f038c 100644 --- a/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2024, Shannon Booth * Copyright (c) 2024, Jamie Mansfield + * Copyright (c) 2025, stelar7 * * SPDX-License-Identifier: BSD-2-Clause */ @@ -16,8 +17,9 @@ GC_DEFINE_ALLOCATOR(IDBOpenDBRequest); IDBOpenDBRequest::~IDBOpenDBRequest() = default; +// NOTE: The source of an open request is always null. IDBOpenDBRequest::IDBOpenDBRequest(JS::Realm& realm) - : IDBRequest(realm) + : IDBRequest(realm, {}) { } diff --git a/Libraries/LibWeb/IndexedDB/IDBRequest.cpp b/Libraries/LibWeb/IndexedDB/IDBRequest.cpp index 3dd39c6bfa4..c1d5b58f29b 100644 --- a/Libraries/LibWeb/IndexedDB/IDBRequest.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBRequest.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2024, Shannon Booth * Copyright (c) 2024, Jamie Mansfield - * Copyright (c) 2024, stelar7 + * Copyright (c) 2024-2025, stelar7 * * SPDX-License-Identifier: BSD-2-Clause */ @@ -16,8 +16,9 @@ GC_DEFINE_ALLOCATOR(IDBRequest); IDBRequest::~IDBRequest() = default; -IDBRequest::IDBRequest(JS::Realm& realm) +IDBRequest::IDBRequest(JS::Realm& realm, IDBRequestSource source) : EventTarget(realm) + , m_source(source) { } @@ -27,6 +28,11 @@ void IDBRequest::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBRequest); } +GC::Ref IDBRequest::create(JS::Realm& realm, IDBRequestSource source) +{ + return realm.create(realm, source); +} + void IDBRequest::visit_edges(Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Libraries/LibWeb/IndexedDB/IDBRequest.h b/Libraries/LibWeb/IndexedDB/IDBRequest.h index 7564c6e6253..e3031a22ccb 100644 --- a/Libraries/LibWeb/IndexedDB/IDBRequest.h +++ b/Libraries/LibWeb/IndexedDB/IDBRequest.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2024, Shannon Booth * Copyright (c) 2024, Jamie Mansfield - * Copyright (c) 2024, stelar7 + * Copyright (c) 2024-2025, stelar7 * * SPDX-License-Identifier: BSD-2-Clause */ @@ -24,6 +24,8 @@ class IDBRequest : public DOM::EventTarget { public: virtual ~IDBRequest() override; + [[nodiscard]] static GC::Ref create(JS::Realm&, IDBRequestSource); + [[nodiscard]] bool done() const { return m_done; } [[nodiscard]] bool processed() const { return m_processed; } [[nodiscard]] IDBRequestSource source() const { return m_source; } @@ -46,7 +48,7 @@ public: WebIDL::CallbackType* onerror(); protected: - explicit IDBRequest(JS::Realm&); + explicit IDBRequest(JS::Realm&, IDBRequestSource); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Visitor& visitor) override;