Truly independent web browser
LibWeb: Throw from IDBRequest.error while the request is pending
Andreas Klingbdd75a85da76
diff --git a/Libraries/LibWeb/IndexedDB/IDBRequest.cpp b/Libraries/LibWeb/IndexedDB/IDBRequest.cppindex 4f2bd02129e..d65fbfabb25 100644--- a/Libraries/LibWeb/IndexedDB/IDBRequest.cpp+++ b/Libraries/LibWeb/IndexedDB/IDBRequest.cpp@@ -103,7 +103,7 @@ WebIDL::CallbackType* IDBRequest::onerror()}// https://w3c.github.io/IndexedDB/#dom-idbrequest-error-[[nodiscard]] GC::Ptr<WebIDL::DOMException> IDBRequest::error() const+WebIDL::ExceptionOr<GC::Ptr<WebIDL::DOMException>> IDBRequest::error() const{// 1. If this's done flag is false, then throw an "InvalidStateError" DOMException.if (!m_done)diff --git a/Libraries/LibWeb/IndexedDB/IDBRequest.h b/Libraries/LibWeb/IndexedDB/IDBRequest.hindex 65eee0ff983..61baa89065b 100644--- a/Libraries/LibWeb/IndexedDB/IDBRequest.h+++ b/Libraries/LibWeb/IndexedDB/IDBRequest.h@@ -41,7 +41,7 @@ public:[[nodiscard]] HTML::WindowOrWorkerGlobalScopeMixin& relevant_global_scope() const;[[nodiscard]] JS::Object& relevant_global_object() const;- [[nodiscard]] GC::Ptr<WebIDL::DOMException> error() const;+ [[nodiscard]] WebIDL::ExceptionOr<GC::Ptr<WebIDL::DOMException>> error() const;[[nodiscard]] WebIDL::ExceptionOr<JS::Value> result() const;[[nodiscard]] Bindings::IDBRequestReadyState ready_state() const;diff --git a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cppindex 846fec39edd..2445e25753c 100644--- a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp+++ b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp@@ -1275,7 +1275,7 @@ void fire_an_error_event(JS::Realm& realm, GC::Ref<IDBRequest> request)// 3. If event’s canceled flag is false, then run abort a transaction using transaction and request's error, and terminate these steps.if (!event->cancelled()) {- abort_a_transaction(*transaction, request->error());+ abort_a_transaction(*transaction, MUST(request->error()));return;}diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.sharedworker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.sharedworker.txtindex 52bbe80682f..0b4b6648e18 100644--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.sharedworker.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.sharedworker.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail IDBRequest.error throws if ready state is pending\ No newline at end of file+1 Pass+Pass IDBRequest.error throws if ready state is pending\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.txtindex 52bbe80682f..0b4b6648e18 100644--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail IDBRequest.error throws if ready state is pending\ No newline at end of file+1 Pass+Pass IDBRequest.error throws if ready state is pending\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.worker.txtindex 52bbe80682f..0b4b6648e18 100644--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.worker.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbrequest_error.any.worker.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail IDBRequest.error throws if ready state is pending\ No newline at end of file+1 Pass+Pass IDBRequest.error throws if ready state is pending\ No newline at end of file