LibWeb: Implement cleanup_indexed_database_transactions
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This commit is contained in:
stelar7 2025-06-16 16:41:29 +02:00 committed by Shannon Booth
commit 3815a7c1eb
Notes: github-actions[bot] 2025-06-18 07:06:49 +00:00
6 changed files with 44 additions and 1 deletions

View file

@ -2051,4 +2051,32 @@ void queue_a_database_task(GC::Ref<GC::Function<void()>> steps)
HTML::queue_a_task(HTML::Task::Source::DatabaseAccess, nullptr, nullptr, steps);
}
// https://w3c.github.io/IndexedDB/#cleanup-indexed-database-transactions
bool cleanup_indexed_database_transactions(GC::Ref<HTML::EventLoop> event_loop)
{
bool has_matching_event_loop = false;
Database::for_each_database([&has_matching_event_loop, event_loop](GC::Root<Database> const& database) {
for (auto const& connection : database->associated_connections()) {
for (auto const& transaction : connection->transactions()) {
// 2. For each transaction transaction with cleanup event loop matching the current event loop:
if (transaction->cleanup_event_loop() == event_loop) {
has_matching_event_loop = true;
// 1. Set transactions state to inactive.
transaction->set_state(IDBTransaction::TransactionState::Inactive);
// 2. Clear transactions cleanup event loop.
transaction->set_cleanup_event_loop(nullptr);
}
}
}
});
// 1. If there are no transactions with cleanup event loop matching the current event loop, return false.
// 3. Return true.
return has_matching_event_loop;
}
}