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 shouldBeUndefined("request.result"); |
| 50 shouldBeNonNull("request.error"); |
49 shouldBe("request.error.name", "'ConstraintError'"); | 51 shouldBe("request.error.name", "'ConstraintError'"); |
50 evalAndLog("request_error = request.error"); | 52 evalAndLog("request_error = request.error"); |
51 }; | 53 }; |
52 trans.oncomplete = unexpectedCompleteCallback; | 54 trans.oncomplete = unexpectedCompleteCallback; |
53 trans.onabort = function() { | 55 trans.onabort = function() { |
54 debug("Transaction received abort event."); | 56 debug("Transaction received abort event."); |
55 shouldBeNonNull("trans.error"); | 57 shouldBeNonNull("trans.error"); |
56 debug("trans.error.message = " + trans.error.message); | 58 debug("trans.error.message = " + trans.error.message); |
57 shouldBeNonNull("trans.error.message"); | 59 shouldBeNonNull("trans.error.message"); |
58 shouldBe("trans.error", "request_error"); | 60 shouldBe("trans.error", "request_error"); |
59 testErrorFromException(); | 61 testErrorFromException(); |
60 }; | 62 }; |
61 } | 63 } |
62 | 64 |
63 function testErrorFromException() | 65 function testErrorFromException() |
64 { | 66 { |
65 debug(""); | 67 debug(""); |
66 debug("If the transaction is aborted due to an exception thrown from event c
allback, IDBTransaction.error should be AbortError:"); | 68 debug("If the transaction is aborted due to an exception thrown from event c
allback, IDBTransaction.error should be AbortError:"); |
67 evalAndLog("trans = db.transaction('storeName', 'readwrite')"); | 69 evalAndLog("trans = db.transaction('storeName', 'readwrite')"); |
68 evalAndLog("request = trans.objectStore('storeName').add('value2', 'key')"); | 70 evalAndLog("request = trans.objectStore('storeName').add('value2', 'key')"); |
69 request.onsuccess = unexpectedSuccessCallback; | 71 request.onsuccess = unexpectedSuccessCallback; |
70 request.onerror = function() { | 72 request.onerror = function() { |
| 73 shouldBeUndefined("request.result"); |
| 74 shouldBeNonNull("request.error"); |
71 shouldBe("request.error.name", "'ConstraintError'"); | 75 shouldBe("request.error.name", "'ConstraintError'"); |
72 debug("Throwing exception..."); | 76 debug("Throwing exception..."); |
73 | 77 |
74 // Ensure the test harness error handler is not invoked. | 78 // Ensure the test harness error handler is not invoked. |
75 self.originalWindowOnError = self.onerror; | 79 self.originalWindowOnError = self.onerror; |
76 self.onerror = null; | 80 self.onerror = null; |
77 | 81 |
78 throw new Error("This should *NOT* be caught!"); | 82 throw new Error("This should *NOT* be caught!"); |
79 }; | 83 }; |
80 trans.oncomplete = unexpectedCompleteCallback; | 84 trans.oncomplete = unexpectedCompleteCallback; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 debug("trans.error.message = " + trans.error.message); | 124 debug("trans.error.message = " + trans.error.message); |
121 shouldBeNonNull("trans.error.message"); | 125 shouldBeNonNull("trans.error.message"); |
122 debug("Note: This fails because of http://wkb.ug/37327"); | 126 debug("Note: This fails because of http://wkb.ug/37327"); |
123 shouldNotBe("trans.error.message.indexOf(indexName)", "-1"); | 127 shouldNotBe("trans.error.message.indexOf(indexName)", "-1"); |
124 debug(""); | 128 debug(""); |
125 finishJSTest(); | 129 finishJSTest(); |
126 }; | 130 }; |
127 }; | 131 }; |
128 }; | 132 }; |
129 } | 133 } |
OLD | NEW |