1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB's basics.");
8 indexedDBTest(prepareDatabase);
9 function prepareDatabase(event)
11 trans = event.target.transaction;
12 db = event.target.result;
14 db.createObjectStore("objectStore");
15 objectStore = trans.objectStore("objectStore");
16 var req1 = objectStore.put({"key": "value"}, "object1");
17 var req2 = objectStore.put({"key": "value"}, "object2");
19 waitForRequests([req1, req2], createIndex);
22 function createIndex() {
23 // This will asynchronously abort in the backend because of constraint failures.
24 evalAndLog("objectStore.createIndex('index', 'key', {unique: true})");
25 // Now immediately delete it.
26 evalAndLog("objectStore.deleteIndex('index')");
27 // Delete it again: backend may have asynchronously aborted the
28 // index creation, but this makes sure the frontend doesn't get
29 // confused and crash, or think the index still exists.
30 evalAndExpectException("objectStore.deleteIndex('index')", "DOMException.NOT_FOUND_ERR", "'NotFoundError'");
31 debug("Now requesting object2");
32 var req3 = objectStore.get("object2");
33 req3.onsuccess = unexpectedSuccessCallback;
34 req3.onerror = deleteIndexAfterGetError;
35 debug("now we wait.");
38 function deleteIndexAfterGetError() {
39 debug("deleteIndexAfterGetError()");
40 // the index should still be gone, and this should not crash.
41 evalAndExpectException("objectStore.deleteIndex('index')", "0", "'TransactionInactiveError'");
42 evalAndExpectException("objectStore.deleteIndex('index')", "0", "'TransactionInactiveError'");