diff options
Diffstat (limited to 'LayoutTests/storage/indexeddb/objectstore-autoincrement.html')
-rw-r--r-- | LayoutTests/storage/indexeddb/objectstore-autoincrement.html | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/LayoutTests/storage/indexeddb/objectstore-autoincrement.html b/LayoutTests/storage/indexeddb/objectstore-autoincrement.html index 2b44a7a..0c0e9f5 100644 --- a/LayoutTests/storage/indexeddb/objectstore-autoincrement.html +++ b/LayoutTests/storage/indexeddb/objectstore-autoincrement.html @@ -68,13 +68,25 @@ function setVersionCompleted() { debug("setVersionCompleted():"); - window.trans = evalAndLog("trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})"); + window.trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)"); trans.onabort = unexpectedAbortCallback; trans.oncomplete = done; window.store = evalAndLog("store = trans.objectStore('StoreWithKeyPath')"); - debug("Insert in object store with key gen and key path"); + debug("Insert into object store with auto increment and key path, with key in the object."); + result = evalAndLog("store.add({name: 'Jeffersson', number: '7010', id: 3})"); + result.onsuccess = addJefferssonSuccess; + result.onerror = unexpectedErrorCallback; +} + +function addJefferssonSuccess() +{ + debug("addJefferssonSuccess():"); + verifySuccessEvent(event); + shouldBe("event.result", "3"); + + debug("Insert into object store with auto increment and key path, without key in the object."); result = evalAndLog("store.add({name: 'Lincoln', number: '7012'})"); result.onsuccess = unexpectedSuccessCallback; result.onerror = addLincolnError; @@ -87,32 +99,21 @@ function addLincolnError() // FIXME: This should be implemented, but we make it an error for now. shouldBe("event.code", "webkitIDBDatabaseException.UNKNOWN_ERR"); + evalAndLog("event.preventDefault()"); + window.store = evalAndLog("store = trans.objectStore('StoreWithAutoIncrement')"); debug("Insert into object store with key gen using explicit key"); - result = evalAndLog("store.add({name: 'Lincoln'}, 1)"); - result.onsuccess = unexpectedSuccessCallback; - result.onerror = addWithExplicitKeyError; -} - -function addWithExplicitKeyError() -{ - debug("addWithExplicitKeyError():"); - verifyErrorEvent(event); - shouldBe("event.code", "webkitIDBDatabaseException.DATA_ERR"); - - debug("Insert into object store with key gen and no key path"); - result = evalAndLog("store.add({name: 'Lincoln', number: '7012'})"); + result = evalAndLog("store.add({name: 'Lincoln', number: '7012'}, 5)"); result.onsuccess = addLincolnSuccess; - result.onerror = unexpectedErrorCallback; } function addLincolnSuccess() { debug("addLincolnSuccess():"); verifySuccessEvent(event); - shouldBe("event.result", "1"); + shouldBe("event.result", "5"); - result = evalAndLog("store.get(1)"); + result = evalAndLog("store.get(5)"); result.onsuccess = getLincolnSuccess; result.onerror = unexpectedErrorCallback; } @@ -133,9 +134,9 @@ function putAbrahamSuccess() { debug("putAbrahamSuccess():"); verifySuccessEvent(event); - shouldBe("event.result", "2"); + shouldBe("event.result", "6"); - result = evalAndLog("store.get(2)"); + result = evalAndLog("store.get(6)"); result.onsuccess = getAbrahamSuccess; result.onerror = unexpectedErrorCallback; } @@ -160,6 +161,8 @@ function addAdamError() verifyErrorEvent(event); shouldBe("event.code", "webkitIDBDatabaseException.DATA_ERR"); + evalAndLog("event.preventDefault()"); + result = evalAndLog("store.add({name: 'Adam'}, 1)"); result.onsuccess = addAdamSuccess; result.onerror = unexpectedErrorCallback; |