Based on the IndexedDB spec, why do open database connections get closed when indexedDB.deleteDatabase is called?

See what the IndexedDB spec says about dropping a database. In particular, I'm worried about what happens if you try to drop a database that still has one or more open connections, like this:

indexedDB.open('test', 1);
indexedDB.deleteDatabase('test');

      

Here's what the spec says:

  1. Fire a changechange event for every object in openDatabases that is open. The event MUST NOT fire on objects with the closePending flag checked. The event MUST use the IDBVersionChangeEvent interface and has the oldVersion property set to db version and the newVersion property set to null. This event MUST NOT be reset or canceled.
  2. If any of the connections on openDatabases are still not closed and the request has been granted, the request fire blocked event. The event MUST use the IDBVersionChangeEvent interface and has the oldVersion property set to db version and the newVersion property set to null. This event MUST NOT be reset or canceled.
  3. Wait until all objects in openDatabases are closed and all their transactions are complete.

I don't understand how step 7 ends. What happens in steps 5 or 6 that actually close one of the open connections? What are these steps even if you allow handlers onversionchange

and onblocked

?

A similar language appears in the steps for executing a "changechange" transaction when you have an open connection to the database that you are trying to bump the version to, for example:

indexedDB.open('test', 1);
indexedDB.open('test', 2);

      

FWIW, the reason I am asking such a mundane question is related to this .

+3


source to share


2 answers


I don't understand how step 7 ends. What happens in steps 5 or 6 that actually close one of the open connections? What are these steps even if you allow onversionchange and onblocked handlers to respond?

What are all these steps doing. UA fires these events and allows the script to close existing connections if it wants to. If the script chooses not to close existing connections, then step 7 does not exit.



This is not documented in the spec because the spec tells the UAs what to do, not the script. Although this should probably be covered in a non-normative introduction.

+3


source


My understanding is all connections should listen to the event versionchange

and close the connection. Otherwise, the new application will not create a new version or drop the database. The new app will just receive the event block

, after all. Note that the method deleteDatabase

returns a request, but the method close

does not.



+2


source







All Articles