diff options
Diffstat (limited to 'LayoutTests/storage/indexeddb/exception-in-event-aborts.html')
-rw-r--r-- | LayoutTests/storage/indexeddb/exception-in-event-aborts.html | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/LayoutTests/storage/indexeddb/exception-in-event-aborts.html b/LayoutTests/storage/indexeddb/exception-in-event-aborts.html new file mode 100644 index 0000000..b49da56 --- /dev/null +++ b/LayoutTests/storage/indexeddb/exception-in-event-aborts.html @@ -0,0 +1,133 @@ +<html> +<head> +<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"> +<script src="../../fast/js/resources/js-test-pre.js"></script> +<script src="../../fast/js/resources/js-test-post-function.js"></script> +<script src="resources/shared.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script> + +description("Test exceptions in IDBRequest handlers cause aborts."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function test() +{ + request = evalAndLog("webkitIndexedDB.open('exception-in-event-aborts')"); + request.onsuccess = setVersion; + request.onerror = unexpectedErrorCallback; +} + +function setVersion() +{ + db = evalAndLog("db = event.target.result"); + + request = evalAndLog("db.setVersion('new version')"); + request.onsuccess = deleteExisting; + request.onerror = unexpectedErrorCallback; +} + +function deleteExisting() +{ + debug("setVersionSuccess():"); + window.trans = evalAndLog("trans = event.target.result"); + shouldBeTrue("trans !== null"); + trans.onabort = unexpectedAbortCallback; + evalAndLog("trans.oncomplete = startTest"); + + deleteAllObjectStores(db); + + store = evalAndLog("store = db.createObjectStore('storeName', null)"); + request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); + request.onerror = unexpectedErrorCallback; +} + +function startTest() +{ + debug(""); + trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)"); + evalAndLog("trans.onabort = transactionAborted1"); + evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); + store = evalAndLog("store = trans.objectStore('storeName')"); + request = evalAndLog("store.add({x: 'value2', y: 'zzz2'}, 'key2')"); + trans.addEventListener('success', causeException, true); + request.onerror = unexpectedErrorCallback; +} + +function causeException() +{ + debug(""); + evalAndLog("event.preventDefault()"); + debug("Throwing"); + throw "this exception is expected"; +} + +function transactionAborted1() +{ + debug(""); + testPassed("The transaction was aborted."); + trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)"); + evalAndLog("trans.onabort = transactionAborted2"); + evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); + store = evalAndLog("store = trans.objectStore('storeName')"); + request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); + request.onsuccess = unexpectedSuccessCallback; + db.onerror = causeException; +} + +function transactionAborted2() +{ + debug(""); + testPassed("The transaction was aborted."); + trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)"); + evalAndLog("trans.onabort = unexpectedAbortCallback"); + evalAndLog("trans.oncomplete = transactionCompleted1"); + store = evalAndLog("store = trans.objectStore('storeName')"); + request = evalAndLog("store.add({x: 'value3', y: 'zzz3'}, 'key3')"); + request.onsuccess = throwAndCatch; + request.onerror = unexpectedErrorCallback; + db.onerror = null; +} + +function throwAndCatch() +{ + debug(""); + evalAndLog("event.preventDefault()"); + debug("Throwing within a try block"); + try { + throw "AHHH"; + } catch (e) { + } +} + +function transactionCompleted1() +{ + debug(""); + testPassed("The transaction completed."); + trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)"); + evalAndLog("trans.onabort = unexpectedAbortCallback"); + evalAndLog("trans.oncomplete = transactionCompleted2"); + store = evalAndLog("store = trans.objectStore('storeName')"); + request = evalAndLog("store.add({x: 'value4', y: 'zzz4'}, 'key4')"); + request.onsuccess = unexpectedSuccessCallback; + request.onerror = throwAndCatch; +} + +function transactionCompleted2() +{ + debug(""); + testPassed("The transaction completed."); + debug(""); + done(); +} + +test(); + +var successfullyParsed = true; + +</script> +</body> +</html> |