LibWeb/IDB: Abort requests in the transactions request list

This commit is contained in:
stelar7 2025-04-09 23:18:18 +02:00 committed by Andrew Kaster
parent a61315a68e
commit 8fcb54dada
Notes: github-actions[bot] 2025-04-11 01:13:53 +00:00

View file

@ -547,12 +547,28 @@ void abort_a_transaction(GC::Ref<IDBTransaction> transaction, GC::Ptr<WebIDL::DO
if (error)
transaction->set_error(error);
// FIXME: 5. For each request of transactions request list, abort the steps to asynchronously execute a request for request,
// set requests processed flag to true, and queue a task to run these steps:
// FIXME: 1. Set requests done flag to true.
// FIXME: 2. Set requests result to undefined.
// FIXME: 3. Set requests error to a newly created "AbortError" DOMException.
// FIXME: 4. Fire an event named error at request with its bubbles and cancelable attributes initialized to true.
// 5. For each request of transactions request list,
for (auto const& request : transaction->request_list()) {
// FIXME: abort the steps to asynchronously execute a request for request,
// set requests processed flag to true
request->set_processed(true);
// and queue a task to run these steps:
HTML::queue_a_task(HTML::Task::Source::DatabaseAccess, nullptr, nullptr, GC::create_function(transaction->realm().vm().heap(), [request]() {
// 1. Set requests done flag to true.
request->set_done(true);
// 2. Set requests result to undefined.
request->set_result(JS::js_undefined());
// 3. Set requests error to a newly created "AbortError" DOMException.
request->set_error(WebIDL::AbortError::create(request->realm(), "Transaction was aborted"_string));
// 4. Fire an event named error at request with its bubbles and cancelable attributes initialized to true.
request->dispatch_event(DOM::Event::create(request->realm(), HTML::EventNames::error, { .bubbles = true, .cancelable = true }));
}));
}
// 6. Queue a task to run these steps:
HTML::queue_a_task(HTML::Task::Source::DatabaseAccess, nullptr, nullptr, GC::create_function(transaction->realm().vm().heap(), [transaction]() {