| OLD | NEW |
| 1 if (this.importScripts) { | 1 if (this.importScripts) { |
| 2 importScripts('../../../resources/js-test.js'); | 2 importScripts('../../../resources/js-test.js'); |
| 3 importScripts('shared.js'); | 3 importScripts('shared.js'); |
| 4 } | 4 } |
| 5 | 5 |
| 6 description("Test IDBTransaction.error cases."); | 6 description("Test IDBTransaction.error cases."); |
| 7 | 7 |
| 8 indexedDBTest(prepareDatabase, startTest); | 8 indexedDBTest(prepareDatabase, startTest); |
| 9 function prepareDatabase() | 9 function prepareDatabase() |
| 10 { | 10 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 function testErrorFromRequest() | 41 function testErrorFromRequest() |
| 42 { | 42 { |
| 43 debug(""); | 43 debug(""); |
| 44 debug("If the transaction is aborted due to a request error that is not prev
ented, IDBTransaction.error should match:"); | 44 debug("If the transaction is aborted due to a request error that is not prev
ented, IDBTransaction.error should match:"); |
| 45 evalAndLog("trans = db.transaction('storeName', 'readwrite')"); | 45 evalAndLog("trans = db.transaction('storeName', 'readwrite')"); |
| 46 evalAndLog("request = trans.objectStore('storeName').add('value2', 'key')"); | 46 evalAndLog("request = trans.objectStore('storeName').add('value2', 'key')"); |
| 47 request.onsuccess = unexpectedSuccessCallback; | 47 request.onsuccess = unexpectedSuccessCallback; |
| 48 request.onerror = function() { | 48 request.onerror = function() { |
| 49 expectError(); |
| 49 shouldBeUndefined("request.result"); | 50 shouldBeUndefined("request.result"); |
| 50 shouldBeNonNull("request.error"); | 51 shouldBeNonNull("request.error"); |
| 51 shouldBe("request.error.name", "'ConstraintError'"); | 52 shouldBe("request.error.name", "'ConstraintError'"); |
| 52 evalAndLog("request_error = request.error"); | 53 evalAndLog("request_error = request.error"); |
| 53 }; | 54 }; |
| 54 trans.oncomplete = unexpectedCompleteCallback; | 55 trans.oncomplete = unexpectedCompleteCallback; |
| 55 trans.onabort = function() { | 56 trans.onabort = function() { |
| 56 debug("Transaction received abort event."); | 57 debug("Transaction received abort event."); |
| 57 shouldBeNonNull("trans.error"); | 58 shouldBeNonNull("trans.error"); |
| 58 debug("trans.error.message = " + trans.error.message); | 59 debug("trans.error.message = " + trans.error.message); |
| 59 shouldBeNonNull("trans.error.message"); | 60 shouldBeNonNull("trans.error.message"); |
| 60 shouldBe("trans.error", "request_error"); | 61 shouldBe("trans.error", "request_error"); |
| 62 |
| 61 testErrorFromException(); | 63 testErrorFromException(); |
| 62 }; | 64 }; |
| 63 } | 65 } |
| 64 | 66 |
| 65 function testErrorFromException() | 67 function testErrorFromException() |
| 66 { | 68 { |
| 67 debug(""); | 69 debug(""); |
| 68 debug("If the transaction is aborted due to an exception thrown from event c
allback, IDBTransaction.error should be AbortError:"); | 70 debug("If the transaction is aborted due to an exception thrown from event c
allback, IDBTransaction.error should be AbortError:"); |
| 69 evalAndLog("trans = db.transaction('storeName', 'readwrite')"); | 71 evalAndLog("trans = db.transaction('storeName', 'readwrite')"); |
| 70 evalAndLog("request = trans.objectStore('storeName').add('value2', 'key')"); | 72 evalAndLog("request = trans.objectStore('storeName').add('value2', 'key')"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 85 trans.onabort = function() { | 87 trans.onabort = function() { |
| 86 debug("Transaction received abort event."); | 88 debug("Transaction received abort event."); |
| 87 | 89 |
| 88 // Restore test harness error handler. | 90 // Restore test harness error handler. |
| 89 self.onerror = self.originalWindowOnError; | 91 self.onerror = self.originalWindowOnError; |
| 90 | 92 |
| 91 shouldBeNonNull("trans.error"); | 93 shouldBeNonNull("trans.error"); |
| 92 debug("trans.error.message = " + trans.error.message); | 94 debug("trans.error.message = " + trans.error.message); |
| 93 shouldBeNonNull("trans.error.message"); | 95 shouldBeNonNull("trans.error.message"); |
| 94 shouldBe("trans.error.name", "'AbortError'"); | 96 shouldBe("trans.error.name", "'AbortError'"); |
| 97 |
| 95 testErrorFromCommit(); | 98 testErrorFromCommit(); |
| 96 }; | 99 }; |
| 97 } | 100 } |
| 98 | 101 |
| 99 function testErrorFromCommit() | 102 function testErrorFromCommit() |
| 100 { | 103 { |
| 101 debug(""); | 104 debug(""); |
| 102 debug("If the transaction is aborted due to an error during commit, IDBTrans
action.error should reflect that error:"); | 105 debug("If the transaction is aborted due to an error during commit, IDBTrans
action.error should reflect that error:"); |
| 103 evalAndLog("trans = db.transaction('storeName', 'readwrite')"); | 106 evalAndLog("trans = db.transaction('storeName', 'readwrite')"); |
| 104 evalAndLog("request = trans.objectStore('storeName').add({id: 1}, 'record1')
"); | 107 evalAndLog("request = trans.objectStore('storeName').add({id: 1}, 'record1')
"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 124 debug("trans.error.message = " + trans.error.message); | 127 debug("trans.error.message = " + trans.error.message); |
| 125 shouldBeNonNull("trans.error.message"); | 128 shouldBeNonNull("trans.error.message"); |
| 126 debug("Note: This fails because of http://wkb.ug/37327"); | 129 debug("Note: This fails because of http://wkb.ug/37327"); |
| 127 shouldNotBe("trans.error.message.indexOf(indexName)", "-1"); | 130 shouldNotBe("trans.error.message.indexOf(indexName)", "-1"); |
| 128 debug(""); | 131 debug(""); |
| 129 finishJSTest(); | 132 finishJSTest(); |
| 130 }; | 133 }; |
| 131 }; | 134 }; |
| 132 }; | 135 }; |
| 133 } | 136 } |
| OLD | NEW |