You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The WPT test for IDBFactory.databases() has a test for Ensure that databases() doesn't pick up changes that haven't commited.
It tests by:
Creating a database
Creating another database, but this time calling IDBFactory.databases() in onupgradeneeded
From my understanding, the database should exist before any attempts to upgrade the database. Open a database connection step 6, creates a new database, and step 10.6 runs the upgrade a database
As such, the result of this
const db1 = await createNamedDatabase(testCase, "DB1", ()=>{});
let databases_promise1;
const db2 = await createNamedDatabase(testCase, "DB2", async () => {
databases_promise1 = indexedDB.databases();
// Give databases() operation a chance to fetch all current info about
// existing databases. This must be a sync sleep since await would trigger
// auto commit of the upgrade transaction.
sleep_sync(1000);
});
const databases_result1 = await databases_promise1;
databases_result1.length should be 2, not 1, as the test expects.
Is there something im missing here? Should maybe databases with version 0 not be counted in this?
(Slightly sad about that sleep_sync(), would be better if there was a get() loop to keep the transaction open)
Easiest path forward is to update the spec to match reality, which would likely be to filter out databases with version 0 as suggested. Feedback about how implementations handle this would be great - if that's how they work, it gives more credence to that proposed approach.
Activity
inexorabletash commentedon Mar 13, 2025
Without looking in detail, your analysis seems correct. Seems like all browsers pass the test as written: https://wpt.fyi/results/IndexedDB/get-databases.any.html?label=master&label=experimental&aligned&q=IndexedDB
(Slightly sad about that
sleep_sync(), would be better if there was aget()loop to keep the transaction open)Easiest path forward is to update the spec to match reality, which would likely be to filter out databases with version 0 as suggested. Feedback about how implementations handle this would be great - if that's how they work, it gives more credence to that proposed approach.
So... more data and PRs welcome!
inexorabletash commentedon Apr 11, 2025
I peeked at the Chromium implementation, and indeed version 0 databases are explicitly excluded from the enumeration.