mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-08 01:51:57 +00:00
LibWeb/IDB: Correctly check if transaction was aborted
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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
The associated databases upgrade transaction could be null at the time we try to access it here.
This commit is contained in:
parent
e8b7447c36
commit
1844e10cd3
Notes:
github-actions[bot]
2025-03-25 10:51:06 +00:00
Author: https://github.com/stelar7
Commit: 1844e10cd3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4033
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 7 additions and 5 deletions
|
@ -120,7 +120,8 @@ WebIDL::ExceptionOr<GC::Ref<IDBDatabase>> open_a_database_connection(JS::Realm&
|
|||
}));
|
||||
|
||||
// 6. Run upgrade a database using connection, version and request.
|
||||
upgrade_a_database(realm, connection, version, request);
|
||||
// AD-HOC: https://github.com/w3c/IndexedDB/issues/433#issuecomment-2512330086
|
||||
auto upgrade_transaction = upgrade_a_database(realm, connection, version, request);
|
||||
|
||||
// 7. If connection was closed, return a newly created "AbortError" DOMException and abort these steps.
|
||||
if (connection->state() == IDBDatabase::ConnectionState::Closed) {
|
||||
|
@ -129,8 +130,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBDatabase>> open_a_database_connection(JS::Realm&
|
|||
|
||||
// 8. If the upgrade transaction was aborted, run the steps to close a database connection with connection,
|
||||
// return a newly created "AbortError" DOMException and abort these steps.
|
||||
auto transaction = connection->associated_database()->upgrade_transaction();
|
||||
if (transaction->aborted()) {
|
||||
if (upgrade_transaction->aborted()) {
|
||||
close_a_database_connection(*connection, true);
|
||||
return WebIDL::AbortError::create(realm, "Upgrade transaction was aborted"_string);
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ void close_a_database_connection(IDBDatabase& connection, bool forced)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#upgrade-a-database
|
||||
void upgrade_a_database(JS::Realm& realm, GC::Ref<IDBDatabase> connection, u64 version, GC::Ref<IDBRequest> request)
|
||||
GC::Ref<IDBTransaction> upgrade_a_database(JS::Realm& realm, GC::Ref<IDBDatabase> connection, u64 version, GC::Ref<IDBRequest> request)
|
||||
{
|
||||
// 1. Let db be connection’s database.
|
||||
auto db = connection->associated_database();
|
||||
|
@ -365,6 +365,8 @@ void upgrade_a_database(JS::Realm& realm, GC::Ref<IDBDatabase> connection, u64 v
|
|||
HTML::main_thread_event_loop().spin_until(GC::create_function(realm.vm().heap(), [&wait_for_transaction]() {
|
||||
return !wait_for_transaction;
|
||||
}));
|
||||
|
||||
return transaction;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#deleting-a-database
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue