Skip to content

Truly independent web browser

LibWeb: Mark stores and indexes of aborted IndexedDB upgrades deleted

Andreas Klingffae61921b7b
diff --git a/Libraries/LibWeb/IndexedDB/Internal/MutationLog.cpp b/Libraries/LibWeb/IndexedDB/Internal/MutationLog.cpp
index df8797ab211..76065104dcc 100644
--- a/Libraries/LibWeb/IndexedDB/Internal/MutationLog.cpp
+++ b/Libraries/LibWeb/IndexedDB/Internal/MutationLog.cpp
@@ -212,6 +212,13 @@ void MutationLog::revert_entries(ObjectStore& store, size_t from_position, GC::P
VERIFY(connection);
database->remove_object_store(store);
connection->remove_from_object_store_set(store);
+
+ // https://w3c.github.io/IndexedDB/#abort-a-transaction
+ // Any object stores and indexes which were created during the transaction are now considered deleted
+ // for the purposes of other algorithms.
+ store.set_deleted(true);
+ for (auto const& [_, index] : store.index_set())
+ index->set_deleted(true);
},
[&](ObjectStoreDeleted&) {
VERIFY(database);
@@ -225,6 +232,11 @@ void MutationLog::revert_entries(ObjectStore& store, size_t from_position, GC::P
[&](IndexCreated& e) {
VERIFY(database);
e.index->object_store()->index_set().remove(e.index->name());
+
+ // https://w3c.github.io/IndexedDB/#abort-a-transaction
+ // Any object stores and indexes which were created during the transaction are now considered deleted
+ // for the purposes of other algorithms.
+ e.index->set_deleted(true);
},
[&](IndexDeleted& e) {
VERIFY(database);
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.txt
index f4e84f70d6b..c67c5cc681f 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.txt
@@ -2,11 +2,10 @@ Harness status: OK
Found 6 tests
-2 Pass
-4 Fail
-Fail Created stores get their indexes marked as deleted after the transaction that created them aborts
+6 Pass
+Pass Created stores get their indexes marked as deleted after the transaction that created them aborts
Pass Deleted stores get their indexes marked as not-deleted after the transaction that deleted them aborts
-Fail Created+deleted stores still have their indexes marked as deleted after the transaction aborts
-Fail Created indexes get marked as deleted after their transaction aborts
+Pass Created+deleted stores still have their indexes marked as deleted after the transaction aborts
+Pass Created indexes get marked as deleted after their transaction aborts
Pass Deleted indexes get marked as not-deleted after the transaction aborts
-Fail Created+deleted indexes are still marked as deleted after their transaction aborts
\ No newline at end of file
+Pass Created+deleted indexes are still marked as deleted after their transaction aborts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.txt
index f4e84f70d6b..c67c5cc681f 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.txt
@@ -2,11 +2,10 @@ Harness status: OK
Found 6 tests
-2 Pass
-4 Fail
-Fail Created stores get their indexes marked as deleted after the transaction that created them aborts
+6 Pass
+Pass Created stores get their indexes marked as deleted after the transaction that created them aborts
Pass Deleted stores get their indexes marked as not-deleted after the transaction that deleted them aborts
-Fail Created+deleted stores still have their indexes marked as deleted after the transaction aborts
-Fail Created indexes get marked as deleted after their transaction aborts
+Pass Created+deleted stores still have their indexes marked as deleted after the transaction aborts
+Pass Created indexes get marked as deleted after their transaction aborts
Pass Deleted indexes get marked as not-deleted after the transaction aborts
-Fail Created+deleted indexes are still marked as deleted after their transaction aborts
\ No newline at end of file
+Pass Created+deleted indexes are still marked as deleted after their transaction aborts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.txt
index 8c38cdca2c9..1d82f34ee14 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 3 tests
-1 Pass
-2 Fail
-Fail Deleted indexes in newly created stores are still marked as deleted after the transaction aborts
+3 Pass
+Pass Deleted indexes in newly created stores are still marked as deleted after the transaction aborts
Pass Deleted indexes in deleted stores are still marked as not-deleted after the transaction aborts
-Fail Deleted indexes in created+deleted stores are still marked as deleted after their transaction aborts
\ No newline at end of file
+Pass Deleted indexes in created+deleted stores are still marked as deleted after their transaction aborts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.txt
index aaba611783b..8c34e6d6a99 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.txt
@@ -2,9 +2,8 @@ Harness status: OK
Found 4 tests
-2 Pass
-2 Fail
-Fail Created stores get marked as deleted after their transaction aborts
+4 Pass
+Pass Created stores get marked as deleted after their transaction aborts
Pass Deleted stores get marked as not-deleted after the transaction aborts
-Fail Created+deleted stores are still marked as deleted after their transaction aborts
+Pass Created+deleted stores are still marked as deleted after their transaction aborts
Pass Un-instantiated deleted stores get marked as not-deleted after the transaction aborts
\ No newline at end of file