5.3. Deleting a database
The steps to delete a database are as follows. The algorithm in these steps takes three arguments: the origin that requested the database to be deleted, a database name, and a request.
Let queue be the connection queue for origin and name.
Add request to queue.
Wait until all previous requests in queue have been processed.
Let db be the database named name in origin, if one exists. Otherwise, return 0 (zero).
Let openConnections be the set of all connections associated with db.
For each entry in openConnections that does not have its close pending flag set, 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.Wait for all of the events to be fired.
If any of the connections in openConnections are still not closed, queue a task to fire a version change event named
[blocked](#request-blocked)
at request with db’s version and null.Wait until all connections in openConnections are closed.
Let version be db’s version.
Delete db. If this fails for any reason, return an appropriate error (e.g. “
[QuotaExceededError](https://www.w3.org/TR/WebIDL-1/#quotaexceedederror)
“ or “[UnknownError](https://www.w3.org/TR/WebIDL-1/#unknownerror)
“[DOMException](https://www.w3.org/TR/WebIDL-1/#idl-DOMException)
).Return version.