Truly independent web browser
LibWeb: Only report committed versions from IDBFactory.databases()
Andreas Kling9a7b16dd5d23
diff --git a/Libraries/LibWeb/IndexedDB/IDBTransaction.h b/Libraries/LibWeb/IndexedDB/IDBTransaction.hindex eee9d6b9f01..31363668ab1 100644--- a/Libraries/LibWeb/IndexedDB/IDBTransaction.h+++ b/Libraries/LibWeb/IndexedDB/IDBTransaction.h@@ -102,6 +102,7 @@ public:// Mutation log management. Logs are per-store and track both data and schema mutations.void set_up_mutation_logs();+ u64 original_version() const { return m_original_version; }void set_up_mutation_log_for_new_store(GC::Ref<ObjectStore>);void revert_all_mutations();void discard_mutation_logs();diff --git a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cppindex 2445e25753c..32829fe0405 100644--- a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp+++ b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp@@ -2659,12 +2659,21 @@ void resolve_database_info_list_promise(JS::Realm& realm, WebIDL::Promise const&u32 result_index = 0;for (auto const& db : databases) {- if (!db || db->version() == 0)+ if (!db)+ continue;++ // INTEROP: A database's version is not reported until its upgrade transaction commits, so that databases()+ // does not pick up changes that have not been committed.+ auto version = db->version();+ if (auto upgrade_transaction = db->upgrade_transaction())+ version = upgrade_transaction->original_version();++ if (version == 0)continue;auto info = JS::Object::create(realm, realm.intrinsics().object_prototype());MUST(info->create_data_property("name"_utf16_fly_string, JS::PrimitiveString::create(realm.vm(), db->name())));- MUST(info->create_data_property("version"_utf16_fly_string, JS::Value(db->version())));+ MUST(info->create_data_property("version"_utf16_fly_string, JS::Value(version)));MUST(result->create_data_property_or_throw(result_index++, info));}diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/get-databases.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/get-databases.any.txtindex 2ad30e0cceb..2283df33cd9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/get-databases.any.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/get-databases.any.txt@@ -2,10 +2,9 @@ Harness status: OKFound 5 tests-4 Pass-1 Fail+5 PassPass Ensure that databases() returns a promise.Pass Enumerate one database.Pass Enumerate multiple databases.Pass Make sure an empty list is returned for the case of no databases.-Fail Ensure that databases() doesn't pick up changes that haven't commited.\ No newline at end of file+Pass Ensure that databases() doesn't pick up changes that haven't commited.\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/get-databases.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/get-databases.any.worker.txtindex 2ad30e0cceb..2283df33cd9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/get-databases.any.worker.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/get-databases.any.worker.txt@@ -2,10 +2,9 @@ Harness status: OKFound 5 tests-4 Pass-1 Fail+5 PassPass Ensure that databases() returns a promise.Pass Enumerate one database.Pass Enumerate multiple databases.Pass Make sure an empty list is returned for the case of no databases.-Fail Ensure that databases() doesn't pick up changes that haven't commited.\ No newline at end of file+Pass Ensure that databases() doesn't pick up changes that haven't commited.\ No newline at end of file