1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Verify that a transaction with an error aborts unless preventDefault() is called.");
8 indexedDBTest(prepareDatabase, addData);
9 function prepareDatabase()
11 db = event.target.result;
12 debug("setVersionSuccess():");
13 self.trans = evalAndLog("trans = event.target.transaction");
14 shouldBeNonNull("trans");
15 trans.onabort = unexpectedAbortCallback;
16 evalAndLog("db.createObjectStore('storeName', null)");
21 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')");
22 evalAndLog("trans.onabort = unexpectedAbortCallback");
23 evalAndLog("trans.oncomplete = transactionCompleted");
24 store = evalAndLog("store = trans.objectStore('storeName')");
25 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
26 request.onsuccess = addMore;
27 request.onerror = unexpectedErrorCallback;
33 request = evalAndLog("event.target.source.add({x: 'value', y: 'zzz'}, 'key')");
34 request.onsuccess = unexpectedSuccessCallback;
35 request.addEventListener("error", preventTheDefault);
38 function preventTheDefault()
40 evalAndLog("event.preventDefault()");
43 function transactionCompleted()
45 testPassed("Transaction completed");
48 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')");
49 evalAndLog("trans.onabort = transactionAborted1");
50 evalAndLog("trans.oncomplete = unexpectedCompleteCallback");
51 store = evalAndLog("store = trans.objectStore('storeName')");
52 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
53 request.onsuccess = unexpectedSuccessCallback;
54 request.onerror = allowDefault;
57 function allowDefault()
59 debug("Doing nothing to prevent the default action...");
62 function transactionAborted1()
64 testPassed("Transaction aborted");
67 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')");
68 evalAndLog("trans.onabort = transactionAborted2");
69 evalAndLog("trans.oncomplete = unexpectedCompleteCallback");
70 store = evalAndLog("store = trans.objectStore('storeName')");
71 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
72 request.onsuccess = unexpectedSuccessCallback;
73 debug("Omitting an onerror handler");
76 function transactionAborted2()
78 testPassed("Transaction aborted");