1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test that deleteDatabase is delayed if a VERSION_CHANGE transaction is running");
8 indexedDBTest(prepareDatabase, onOpenSuccess);
9 function prepareDatabase(evt)
12 evalAndLog("sawVersionChange = false");
13 evalAndLog("upgradeTransactionComplete = false");
14 evalAndLog("h = event.target.result");
16 h.onversionchange = function onVersionChange(evt) {
18 shouldBe("event.target.version", "1");
19 shouldBe("event.oldVersion", "1");
20 shouldBeNull("event.newVersion");
21 evalAndLog("sawVersionChange = true");
22 debug("Connection is not closed, so 'blocked' should fire");
25 transaction = event.target.transaction;
26 transaction.oncomplete = function transactionOnComplete(evt) {
28 evalAndLog("upgradeTransactionComplete = true");
31 request = evalAndLog("indexedDB.deleteDatabase(dbname)");
32 request.onerror = unexpectedErrorCallback;
33 request.onblocked = function deleteDatabaseOnBlocked(evt) {
35 shouldBeTrue("sawVersionChange");
37 request.onsuccess = function deleteDatabaseOnSuccess(evt) {
39 shouldBeTrue("upgradeTransactionComplete");
44 function onOpenSuccess(evt)
47 evalAndLog("h = event.target.result");
48 evalAndLog("h.close()");
49 debug("Closing too late to prevent the in-flight 'blocked' event");
50 // Event ordering between 'success' and 'blocked' is not strictly defined
51 // in the spec. This documents current Chromium behavior to detect
52 // unexpected changes.