1 if (this.importScripts) {
2 importScripts('../../../fast/js/resources/js-test-pre.js');
3 importScripts('shared.js');
6 description("Test transaction aborts send the proper onabort messages..");
10 removeVendorPrefixes();
12 request = evalAndLog("indexedDB.open('name')");
13 request.onsuccess = setVersion;
14 request.onerror = unexpectedErrorCallback;
19 db = evalAndLog("db = event.target.result");
21 request = evalAndLog("db.setVersion('new version')");
22 request.onsuccess = deleteExisting;
23 request.onerror = unexpectedErrorCallback;
26 function deleteExisting()
28 debug("setVersionSuccess():");
29 self.trans = evalAndLog("trans = event.target.result");
30 shouldBeNonNull("trans");
31 trans.onabort = unexpectedAbortCallback;
32 evalAndLog("trans.oncomplete = startTest");
34 deleteAllObjectStores(db);
36 store = evalAndLog("store = db.createObjectStore('storeName', null)");
37 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
38 request.onerror = unexpectedErrorCallback;
43 trans = evalAndLog("trans = db.transaction(['storeName'], 'readwrite')");
44 evalAndLog("trans.onabort = transactionAborted");
45 evalAndLog("trans.oncomplete = unexpectedCompleteCallback");
46 store = evalAndLog("store = trans.objectStore('storeName')");
47 request = evalAndLog("store.add({x: 'value2', y: 'zzz2'}, 'key2')");
48 request.onerror = firstAdd;
49 request.onsuccess = unexpectedSuccessCallback;
50 request = evalAndLog("store.add({x: 'value3', y: 'zzz3'}, 'key3')");
51 request.onerror = secondAdd;
52 request.onsuccess = unexpectedSuccessCallback;
62 shouldBe("event.target.errorCode", "DOMException.ABORT_ERR");
63 shouldBe("event.target.error.name", "'AbortError'");
64 shouldBeNull("trans.error");
65 shouldBeFalse("firstError");
66 shouldBeFalse("secondError");
67 shouldBeFalse("abortFired");
70 evalAndExpectException("store.add({x: 'value4', y: 'zzz4'}, 'key4')", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
75 shouldBe("event.target.errorCode", "DOMException.ABORT_ERR");
76 shouldBe("event.target.error.name", "'AbortError'");
77 shouldBeNull("trans.error");
78 shouldBeTrue("firstError");
79 shouldBeFalse("secondError");
80 shouldBeFalse("abortFired");
84 function transactionAborted()
86 shouldBeTrue("firstError");
87 shouldBeTrue("secondError");
88 shouldBeFalse("abortFired");
89 shouldBeNull("trans.error");
92 evalAndExpectException("store.add({x: 'value5', y: 'zzz5'}, 'key5')", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
94 evalAndExpectException("trans.abort()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");