Skip to content

Possible wrong WPT test? #442

Closed
Closed

Description

@stelar7

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?

Activity

  1. inexorabletash commented on Mar 13, 2025

    @inexorabletash
    Member

    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 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.

    So... more data and PRs welcome!

  2. inexorabletash commented on Apr 11, 2025

    @inexorabletash
    Member

    I peeked at the Chromium implementation, and indeed version 0 databases are explicitly excluded from the enumeration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址