1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB transaction rollback.");
8 indexedDBTest(prepareDatabase, setVersionComplete);
9 function prepareDatabase()
11 db = event.target.result;
12 event.target.transaction.onabort = unexpectedAbortCallback;
13 evalAndLog("db.createObjectStore('myObjectStore')");
14 shouldBe("db.objectStoreNames.length", "1");
17 function setVersionComplete()
19 debug("setVersionComplete():");
21 self.transaction = evalAndLog("transaction = db.transaction(['myObjectStore'], 'readwrite')");
22 transaction.onabort = abortCallback;
23 transaction.oncomplete = unexpectedCompleteCallback;
25 self.store = evalAndLog("store = transaction.objectStore('myObjectStore')");
26 request = evalAndLog("store.add('rollbackValue', 'rollbackKey123')");
27 request.onsuccess = addSuccess;
28 request.onerror = unexpectedErrorCallback;
33 debug("addSuccess():");
34 shouldBeEqualToString("event.target.result", "rollbackKey123");
36 request = evalAndLog("store.openCursor()");
37 request.onsuccess = openCursorSuccess;
38 request.onerror = unexpectedErrorCallback;
41 function openCursorSuccess()
43 debug("openCursorSuccess():");
44 self.cursor = evalAndLog("cursor = event.target.result");
49 function abortCallback()
51 debug("abortCallback():");
52 debug('Transaction was aborted.');
54 self.transaction = evalAndLog("transaction = db.transaction(['myObjectStore'], 'readonly')");
55 self.store = evalAndLog("store = transaction.objectStore('myObjectStore')");
56 request = evalAndLog("store.get('rollbackKey123')");
57 request.onerror = unexpectedErrorCallback;
58 request.onsuccess = getSuccess;
63 debug("getSuccess():");
64 shouldBe("event.target.result", "undefined");
66 shouldBeEqualToString("cursor.value", "rollbackValue");