1 <html> 2 <head> 3 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"> 4 <script src="../../fast/js/resources/js-test-pre.js"></script> 5 <script src="../../fast/js/resources/js-test-post-function.js"></script> 6 <script src="resources/shared.js"></script> 7 </head> 8 <body> 9 <p id="description"></p> 10 <div id="console"></div> 11 <script> 12 13 description("Test transaction aborts send the proper onabort messages.."); 14 if (window.layoutTestController) 15 layoutTestController.waitUntilDone(); 16 17 function test() 18 { 19 request = evalAndLog("webkitIndexedDB.open('name')"); 20 request.onsuccess = setVersion; 21 request.onerror = unexpectedErrorCallback; 22 } 23 24 function setVersion() 25 { 26 db = evalAndLog("db = event.target.result"); 27 28 request = evalAndLog("db.setVersion('new version')"); 29 request.onsuccess = deleteExisting; 30 request.onerror = unexpectedErrorCallback; 31 } 32 33 function deleteExisting() 34 { 35 debug("setVersionSuccess():"); 36 window.trans = evalAndLog("trans = event.target.result"); 37 shouldBeTrue("trans !== null"); 38 trans.onabort = unexpectedAbortCallback; 39 evalAndLog("trans.oncomplete = startTest"); 40 41 deleteAllObjectStores(db); 42 43 store = evalAndLog("store = db.createObjectStore('storeName', null)"); 44 request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); 45 request.onerror = unexpectedErrorCallback; 46 } 47 48 function startTest() 49 { 50 trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)"); 51 evalAndLog("trans.onabort = transactionAborted"); 52 evalAndLog("trans.oncomplete = unexpectedCompleteCallback"); 53 store = evalAndLog("store = trans.objectStore('storeName')"); 54 request = evalAndLog("store.add({x: 'value2', y: 'zzz2'}, 'key2')"); 55 request.onerror = firstAdd; 56 request.onsuccess = unexpectedSuccessCallback; 57 request = evalAndLog("store.add({x: 'value3', y: 'zzz3'}, 'key3')"); 58 request.onerror = secondAdd; 59 trans.abort(); 60 61 firstError = false; 62 secondError = false; 63 abortFired = false; 64 } 65 66 function firstAdd() 67 { 68 shouldBe("event.target.errorCode", "webkitIDBDatabaseException.ABORT_ERR"); 69 shouldBeFalse("firstError"); 70 shouldBeFalse("secondError"); 71 shouldBeFalse("abortFired"); 72 firstError = true; 73 74 evalAndExpectException("store.add({x: 'value4', y: 'zzz4'}, 'key4')", "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); 75 } 76 77 function secondAdd() 78 { 79 shouldBe("event.target.errorCode", "webkitIDBDatabaseException.ABORT_ERR"); 80 shouldBeTrue("firstError"); 81 shouldBeFalse("secondError"); 82 shouldBeFalse("abortFired"); 83 secondError = true; 84 } 85 86 function transactionAborted() 87 { 88 shouldBeTrue("firstError"); 89 shouldBeTrue("secondError"); 90 shouldBeFalse("abortFired"); 91 abortFired = true; 92 93 evalAndExpectException("store.add({x: 'value5', y: 'zzz5'}, 'key5')", "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); 94 done(); 95 } 96 97 test(); 98 99 var successfullyParsed = true; 100 101 </script> 102 </body> 103 </html> 104