1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB's IDBObjectStore.deleteObjectStore().");
8 indexedDBTest(prepareDatabase, getValue);
9 function prepareDatabase()
11 db = event.target.result;
12 event.target.transaction.onabort = unexpectedAbortCallback;
13 store = evalAndLog("store = db.createObjectStore('storeName', null)");
15 self.index = evalAndLog("store.createIndex('indexName', '')");
16 shouldBeTrue("store.indexNames.contains('indexName')");
18 request = evalAndLog("store.add('value', 'key')");
19 request.onerror = unexpectedErrorCallback;
24 transaction = evalAndLog("db.transaction(['storeName'])");
25 transaction.onabort = unexpectedErrorCallback;
26 transaction.oncomplete = addIndex;
27 var store = evalAndLog("store = transaction.objectStore('storeName')");
29 request = evalAndLog("store.get('key')");
30 request.onsuccess = checkResult;
31 request.onerror = unexpectedErrorCallback;
34 function checkResult()
36 shouldBeEqualToString("event.target.result", "value");
41 evalAndLog("db.close()");
43 request = evalAndLog("indexedDB.open(dbname, 2)");
44 request.onupgradeneeded = deleteObjectStore;
45 request.onerror = unexpectedErrorCallback;
46 request.onsuccess = getValueAgain;
47 request.onblocked = unexpectedBlockedCallback;
50 function deleteObjectStore()
52 trans = request.transaction;
54 trans.onabort = unexpectedAbortCallback;
56 evalAndLog("db.deleteObjectStore('storeName')");
57 createObjectStoreAgain();
60 function createObjectStoreAgain()
62 evalAndLog("db.createObjectStore('storeName', null)");
65 function getValueAgain()
67 transaction = evalAndLog("db.transaction(['storeName'])");
68 transaction.onabort = unexpectedErrorCallback;
69 var store = evalAndLog("store = transaction.objectStore('storeName')");
71 request = evalAndLog("store.get('key')");
72 request.onsuccess = verifyNotFound;
73 request.onerror = unexpectedErrorCallback;
76 function verifyNotFound()
78 shouldBe("event.target.result", "undefined");
79 shouldBeFalse("event.target.source.indexNames.contains('indexName')");