1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB IDBDatabase internal delete pending flag");
8 indexedDBTest(prepareDatabase, testDatabaseDelete, {"version": 5});
9 function prepareDatabase()
11 connection = event.target.result;
12 evalAndLog("connection.createObjectStore('store')");
13 shouldBe("connection.objectStoreNames.length", "1");
16 function testDatabaseDelete()
19 debug("Issue a delete request against the database - should be blocked by the open connection:");
20 evalAndLog("deleteRequest = indexedDB.deleteDatabase(dbname)");
21 deleteRequest.onerror = unexpectedErrorCallback;
22 evalAndLog("state = 0");
25 debug("Open a second connection - should be delayed:");
26 evalAndLog("openRequest = indexedDB.open(dbname)");
27 openRequest.onerror = unexpectedErrorCallback;
29 connection.onversionchange = function() {
31 debug("connection received versionchange event - ignoring.");
32 shouldBe("++state", "1");
35 deleteRequest.onblocked = function() {
37 debug("deleteRequest received blocked event.");
38 shouldBe("++state", "2");
39 evalAndLog("connection.close()");
40 debug("deleteRequest should now be unblocked.");
43 deleteRequest.onsuccess = function() {
45 debug("deleteRequest received success event.");
46 shouldBe("++state", "3");
47 debug("openRequest should now be unblocked.");
50 openRequest.onsuccess = function() {
52 testPassed("openRequest received success event.");
53 shouldBe("++state", "4");
54 evalAndLog("connection2 = openRequest.result");
56 debug("connection2 should reference a different database:");
57 shouldBeFalse("connection2.version == connection.version");
58 shouldBe("connection2.objectStoreNames.length", "0");