1. Let queue be the for origin and name.

    2. Add request to queue.

    3. Wait until all previous requests in queue have been processed.

    4. Let db be the database name in origin, or null otherwise.

    5. If version is undefined, let version be 1 if db is null, or db’s version otherwise.

    6. Let connection be a new to db.

    7. Set connection’s version to version.

    8. If db’s is less than version, then:

      1. Let openConnections be the set of all , except connection, associated with db.

      2. If any of the connections in openConnections are still not closed, to fire a version change event named at request with db’s version and version.

      3. Wait until all in openConnections are closed.

      4. Run using connection, version and request.

      5. If connection was closed, return a newly ““ [DOMException](https://heycam.github.io/webidl/#idl-DOMException) and abort these steps.

    9. Return connection.