From 2265570c88f01251ef51f0ea083271f895c70977 Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Mon, 23 Jun 2025 23:47:03 -0700 Subject: [PATCH] [IndexedDB] Fix upgrade version operation (#37653) Rejects version upgrade if the upgraded version is lower than the current database version. Also returns the actual version instead of the requested upgrade version. Testing: WPT tests might cover this Fixes: #25322 Signed-off-by: Ashwin Naren --- components/net/indexeddb/idb_thread.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/components/net/indexeddb/idb_thread.rs b/components/net/indexeddb/idb_thread.rs index 0cdd4d56fdf..5a99359cc36 100644 --- a/components/net/indexeddb/idb_thread.rs +++ b/components/net/indexeddb/idb_thread.rs @@ -319,13 +319,14 @@ impl IndexedDBManager { }, SyncOperation::UpgradeVersion(sender, origin, db_name, _txn, version) => { if let Some(db) = self.get_database_mut(origin, db_name) { - db.version = version; - }; - - // FIXME:(arihant2math) Get the version from the database instead - // We never fail as of now, so we can just return it like this - // for now... - sender.send(Ok(version)).expect("Could not upgrade version"); + if version > db.version { + db.version = version; + } + // erroring out if the version is not upgraded can be and non-replicable + let _ = sender.send(Ok(db.version)); + } else { + let _ = sender.send(Err(())); + } }, SyncOperation::CreateObjectStore( sender,