[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 <arihant2math@gmail.com>
This commit is contained in:
Ashwin Naren 2025-06-23 23:47:03 -07:00 committed by GitHub
parent 94a7428912
commit 2265570c88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,