| 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 IndexedDB transaction basics."); | 6 description("Test IndexedDB transaction basics."); |
| 7 | 7 |
| 8 indexedDBTest(prepareDatabase, testSetVersionAbort1); | 8 indexedDBTest(prepareDatabase, testSetVersionAbort1); |
| 9 function prepareDatabase() | 9 function prepareDatabase() |
| 10 { | 10 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 var store = evalAndLog("store = db.createObjectStore('storeFail', null)"); | 31 var store = evalAndLog("store = db.createObjectStore('storeFail', null)"); |
| 32 var index = evalAndLog("index = store.createIndex('indexFail', 'x')"); | 32 var index = evalAndLog("index = store.createIndex('indexFail', 'x')"); |
| 33 | 33 |
| 34 evalAndLog("db.deleteObjectStore('storeFail')"); | 34 evalAndLog("db.deleteObjectStore('storeFail')"); |
| 35 evalAndExpectException("store.deleteIndex('indexFail')", "DOMException.INVAL
ID_STATE_ERR", "'InvalidStateError'"); | 35 evalAndExpectException("store.deleteIndex('indexFail')", "DOMException.INVAL
ID_STATE_ERR", "'InvalidStateError'"); |
| 36 | 36 |
| 37 trans.abort(); | 37 trans.abort(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 function testSetVersionAbort2() | 40 function testSetVersionAbort2(evt) |
| 41 { | 41 { |
| 42 debug(""); | 42 preamble(evt); |
| 43 debug("testSetVersionAbort2():"); | 43 evt.preventDefault(); |
| 44 |
| 44 checkMetadataEmpty(); | 45 checkMetadataEmpty(); |
| 45 evalAndLog("request = newConnection()"); | 46 evalAndLog("request = newConnection()"); |
| 46 request.onupgradeneeded = addRemoveAddIDBObjects; | 47 request.onupgradeneeded = addRemoveAddIDBObjects; |
| 47 request.onerror = null; | 48 request.onerror = function(e) { e.preventDefault(); }; |
| 48 } | 49 } |
| 49 | 50 |
| 50 function addRemoveAddIDBObjects() | 51 function addRemoveAddIDBObjects() |
| 51 { | 52 { |
| 52 debug("addRemoveAddIDBObjects():"); | 53 debug("addRemoveAddIDBObjects():"); |
| 53 db = event.target.result; | 54 db = event.target.result; |
| 54 var trans = evalAndLog("trans = event.target.transaction"); | 55 var trans = evalAndLog("trans = event.target.transaction"); |
| 55 shouldBeNonNull("trans"); | 56 shouldBeNonNull("trans"); |
| 56 trans.addEventListener('abort', testSetVersionAbort3, false); | 57 trans.onabort = testSetVersionAbort3; |
| 57 trans.oncomplete = unexpectedCompleteCallback; | 58 trans.oncomplete = unexpectedCompleteCallback; |
| 58 | 59 |
| 59 var store = evalAndLog("store = db.createObjectStore('storeFail', null)"); | 60 var store = evalAndLog("store = db.createObjectStore('storeFail', null)"); |
| 60 var index = evalAndLog("index = store.createIndex('indexFail', 'x')"); | 61 var index = evalAndLog("index = store.createIndex('indexFail', 'x')"); |
| 61 | 62 |
| 62 evalAndLog("db.deleteObjectStore('storeFail')"); | 63 evalAndLog("db.deleteObjectStore('storeFail')"); |
| 63 evalAndExpectException("store.deleteIndex('indexFail')", "DOMException.INVAL
ID_STATE_ERR", "'InvalidStateError'"); | 64 evalAndExpectException("store.deleteIndex('indexFail')", "DOMException.INVAL
ID_STATE_ERR", "'InvalidStateError'"); |
| 64 | 65 |
| 65 var store = evalAndLog("store = db.createObjectStore('storeFail', null)"); | 66 store = evalAndLog("store = db.createObjectStore('storeFail', null)"); |
| 66 var index = evalAndLog("index = store.createIndex('indexFail', 'x')"); | 67 index = evalAndLog("index = store.createIndex('indexFail', 'x')"); |
| 67 | 68 |
| 68 trans.abort(); | 69 trans.abort(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 function testSetVersionAbort3() | 72 function testSetVersionAbort3(evt) |
| 72 { | 73 { |
| 73 debug(""); | 74 preamble(evt); |
| 74 debug("testSetVersionAbort3():"); | 75 |
| 75 shouldBeFalse("event.cancelable"); | 76 shouldBeFalse("event.cancelable"); |
| 76 checkMetadataEmpty(); | 77 checkMetadataEmpty(); |
| 77 evalAndLog("request = newConnection()"); | 78 evalAndLog("request = newConnection()"); |
| 78 request.onupgradeneeded = addIDBObjects; | 79 request.onupgradeneeded = addIDBObjects; |
| 79 request.onsuccess = unexpectedSuccessCallback; | 80 request.onsuccess = unexpectedSuccessCallback; |
| 80 request.onerror = testSetVersionAbort4; | 81 request.onerror = testSetVersionAbort4; |
| 81 } | 82 } |
| 82 | 83 |
| 83 function addIDBObjects() | 84 function addIDBObjects() |
| 84 { | 85 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 107 evalAndExpectException("index.count()", "0", "'TransactionInactiveError'"); | 108 evalAndExpectException("index.count()", "0", "'TransactionInactiveError'"); |
| 108 | 109 |
| 109 evalAndExpectException("store.put(0, 0)", "0", "'TransactionInactiveError'")
; | 110 evalAndExpectException("store.put(0, 0)", "0", "'TransactionInactiveError'")
; |
| 110 evalAndExpectException("store.add(0, 0)", "0", "'TransactionInactiveError'")
; | 111 evalAndExpectException("store.add(0, 0)", "0", "'TransactionInactiveError'")
; |
| 111 evalAndExpectException("store.delete(0)", "0", "'TransactionInactiveError'")
; | 112 evalAndExpectException("store.delete(0)", "0", "'TransactionInactiveError'")
; |
| 112 evalAndExpectException("store.clear()", "0", "'TransactionInactiveError'"); | 113 evalAndExpectException("store.clear()", "0", "'TransactionInactiveError'"); |
| 113 evalAndExpectException("store.get(0)", "0", "'TransactionInactiveError'"); | 114 evalAndExpectException("store.get(0)", "0", "'TransactionInactiveError'"); |
| 114 evalAndExpectException("store.openCursor()", "0", "'TransactionInactiveError
'"); | 115 evalAndExpectException("store.openCursor()", "0", "'TransactionInactiveError
'"); |
| 115 } | 116 } |
| 116 | 117 |
| 117 function testSetVersionAbort4() | 118 function testSetVersionAbort4(evt) |
| 118 { | 119 { |
| 119 debug(""); | 120 preamble(evt); |
| 120 debug("testSetVersionAbort4():"); | 121 evt.preventDefault(); |
| 122 |
| 121 checkMetadataEmpty(); | 123 checkMetadataEmpty(); |
| 122 evalAndLog("request = newConnection()"); | 124 evalAndLog("request = newConnection()"); |
| 123 request.onupgradeneeded = addIDBObjectsAndCommit; | 125 request.onupgradeneeded = addIDBObjectsAndCommit; |
| 124 request.onerror = unexpectedErrorCallback; | 126 request.onerror = unexpectedErrorCallback; |
| 125 request.onsuccess = testSetVersionAbort5; | 127 request.onsuccess = testSetVersionAbort5; |
| 126 } | 128 } |
| 127 | 129 |
| 128 function addIDBObjectsAndCommit() | 130 function addIDBObjectsAndCommit() |
| 129 { | 131 { |
| 130 db = event.target.result; | 132 db = event.target.result; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 shouldBeNonNull("trans"); | 178 shouldBeNonNull("trans"); |
| 177 trans.oncomplete = unexpectedCompleteCallback; | 179 trans.oncomplete = unexpectedCompleteCallback; |
| 178 | 180 |
| 179 var store = evalAndLog("store = trans.objectStore('storeFail')"); | 181 var store = evalAndLog("store = trans.objectStore('storeFail')"); |
| 180 evalAndLog("store.deleteIndex('indexFail')"); | 182 evalAndLog("store.deleteIndex('indexFail')"); |
| 181 evalAndLog("db.deleteObjectStore('storeFail')"); | 183 evalAndLog("db.deleteObjectStore('storeFail')"); |
| 182 | 184 |
| 183 trans.abort(); | 185 trans.abort(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 function testSetVersionAbort6() | 188 function testSetVersionAbort6(evt) |
| 187 { | 189 { |
| 188 debug(""); | 190 preamble(evt); |
| 189 debug("testSetVersionAbort6():"); | 191 evt.preventDefault(); |
| 192 |
| 190 checkMetadataExistingObjectStore(); | 193 checkMetadataExistingObjectStore(); |
| 191 evalAndLog("request = newConnection()"); | 194 evalAndLog("request = newConnection()"); |
| 192 request.onupgradeneeded = setVersionSuccess; | 195 request.onupgradeneeded = setVersionSuccess; |
| 193 request.onsuccess = completeCallback; | 196 request.onsuccess = completeCallback; |
| 194 } | 197 } |
| 195 | 198 |
| 196 function checkMetadataEmpty() | 199 function checkMetadataEmpty() |
| 197 { | 200 { |
| 198 shouldBe("self.db.objectStoreNames", "[]"); | 201 shouldBe("self.db.objectStoreNames", "[]"); |
| 199 shouldBe("self.db.objectStoreNames.length", "0"); | 202 shouldBe("self.db.objectStoreNames.length", "0"); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 trans.oncomplete = verifyDegenerateNames; | 292 trans.oncomplete = verifyDegenerateNames; |
| 290 }; | 293 }; |
| 291 function verifyDegenerateNames() { | 294 function verifyDegenerateNames() { |
| 292 shouldNotThrow("transaction = db.transaction(null)"); | 295 shouldNotThrow("transaction = db.transaction(null)"); |
| 293 shouldBeNonNull("transaction.objectStore('null')"); | 296 shouldBeNonNull("transaction.objectStore('null')"); |
| 294 shouldNotThrow("transaction = db.transaction(undefined)"); | 297 shouldNotThrow("transaction = db.transaction(undefined)"); |
| 295 shouldBeNonNull("transaction.objectStore('undefined')"); | 298 shouldBeNonNull("transaction.objectStore('undefined')"); |
| 296 finishJSTest(); | 299 finishJSTest(); |
| 297 } | 300 } |
| 298 } | 301 } |
| OLD | NEW |