1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test transaction aborts send the proper onabort messages..");
8 indexedDBTest(prepareDatabase, startTest);
9 function prepareDatabase()
11 db = event.target.result;
12 store = evalAndLog("store = db.createObjectStore('storeName', null)");
13 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
14 request.onerror = unexpectedErrorCallback;
19 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')");
20 evalAndLog("trans.onabort = transactionAborted");
21 evalAndLog("trans.oncomplete = unexpectedCompleteCallback");
22 store = evalAndLog("store = trans.objectStore('storeName')");
23 request = evalAndLog("store.add({x: 'value2', y: 'zzz2'}, 'key2')");
24 request.onerror = firstAdd;
25 request.onsuccess = unexpectedSuccessCallback;
26 request = evalAndLog("store.add({x: 'value3', y: 'zzz3'}, 'key3')");
27 request.onerror = secondAdd;
28 request.onsuccess = unexpectedSuccessCallback;
38 shouldBe("event.target.error.name", "'AbortError'");
39 shouldBeNull("trans.error");
40 shouldBeFalse("firstError");
41 shouldBeFalse("secondError");
42 shouldBeFalse("abortFired");
45 evalAndExpectException("store.add({x: 'value4', y: 'zzz4'}, 'key4')", "0", "'TransactionInactiveError'");
50 shouldBe("event.target.error.name", "'AbortError'");
51 shouldBeNull("trans.error");
52 shouldBeTrue("firstError");
53 shouldBeFalse("secondError");
54 shouldBeFalse("abortFired");
58 function transactionAborted()
60 shouldBeTrue("firstError");
61 shouldBeTrue("secondError");
62 shouldBeFalse("abortFired");
63 shouldBeNull("trans.error");
66 evalAndExpectException("store.add({x: 'value5', y: 'zzz5'}, 'key5')", "0", "'TransactionInactiveError'");
68 evalAndExpectException("trans.abort()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");