5.3. Deleting a database

To delete a database with the origin that requested the database to be deleted, a database name, and a request, run these steps:

  1. Let queue be the connection queue 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 named name in origin, if one exists. Otherwise, return 0 (zero).

  5. Let openConnections be the set of all connections associated with db.

  6. For each entry of openConnections that does not have its close pending flag set to true, queue a task to fire a version change event named versionchange at entry with db’s version and null.

    Firing this event might cause one or more of the other objects in openConnections to be closed, in which case the versionchange event is not fired at those objects, even if that hasn’t yet been done.

  7. Wait for all of the events to be fired.

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

  9. Wait until all connections in openConnections are closed.

  10. Let version be db’s version.

  11. Delete db. If this fails for any reason, return an appropriate error (e.g. “[QuotaExceededError](https://heycam.github.io/webidl/#quotaexceedederror)“ or “[UnknownError](https://heycam.github.io/webidl/#unknownerror)[DOMException](https://heycam.github.io/webidl/#idl-DOMException)).

  12. Return version.