mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/IDB: Dont go back to inactive if we finished during upgrade
This commit is contained in:
parent
aa4e303b9f
commit
0a298dba27
Notes:
github-actions[bot]
2025-04-11 01:13:36 +00:00
Author: https://github.com/stelar7
Commit: 0a298dba27
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4306
Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 17 additions and 13 deletions
|
@ -401,21 +401,25 @@ GC::Ref<IDBTransaction> upgrade_a_database(JS::Realm& realm, GC::Ref<IDBDatabase
|
||||||
// 5. Let didThrow be the result of firing a version change event named upgradeneeded at request with old version and version.
|
// 5. Let didThrow be the result of firing a version change event named upgradeneeded at request with old version and version.
|
||||||
auto did_throw = fire_a_version_change_event(realm, HTML::EventNames::upgradeneeded, request, old_version, version);
|
auto did_throw = fire_a_version_change_event(realm, HTML::EventNames::upgradeneeded, request, old_version, version);
|
||||||
|
|
||||||
// 6. Set transaction’s state to inactive.
|
// AD-HOC: If the transaction was aborted by the event, then DONT set the transaction back to inactive.
|
||||||
transaction->set_state(IDBTransaction::TransactionState::Inactive);
|
// https://github.com/w3c/IndexedDB/issues/436#issuecomment-2791113467
|
||||||
|
if (transaction->state() != IDBTransaction::TransactionState::Finished) {
|
||||||
|
|
||||||
// 7. If didThrow is true, run abort a transaction with transaction and a newly created "AbortError" DOMException.
|
// 6. Set transaction’s state to inactive.
|
||||||
if (did_throw)
|
transaction->set_state(IDBTransaction::TransactionState::Inactive);
|
||||||
abort_a_transaction(*transaction, WebIDL::AbortError::create(realm, "Version change event threw an exception"_string));
|
|
||||||
|
|
||||||
// AD-HOC:
|
// 7. If didThrow is true, run abort a transaction with transaction and a newly created "AbortError" DOMException.
|
||||||
// https://github.com/w3c/IndexedDB/issues/436
|
if (did_throw)
|
||||||
// The implementation must attempt to commit a transaction when all requests placed against the transaction have completed
|
abort_a_transaction(transaction, WebIDL::AbortError::create(realm, "Version change event threw an exception"_string));
|
||||||
// and their returned results handled,
|
|
||||||
// no new requests have been placed against the transaction,
|
// AD-HOC:
|
||||||
// and the transaction has not been aborted.
|
// The implementation must attempt to commit a transaction when all requests placed against the transaction have completed
|
||||||
if (transaction->state() == IDBTransaction::TransactionState::Inactive && transaction->request_list().is_empty() && !transaction->aborted())
|
// and their returned results handled,
|
||||||
commit_a_transaction(realm, transaction);
|
// no new requests have been placed against the transaction,
|
||||||
|
// and the transaction has not been aborted.
|
||||||
|
if (transaction->state() == IDBTransaction::TransactionState::Inactive && transaction->request_list().is_empty() && !transaction->aborted())
|
||||||
|
commit_a_transaction(realm, transaction);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// 11. Wait for transaction to finish.
|
// 11. Wait for transaction to finish.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue