blob: 266866c15271ee784e300730d0c82b64ff301189 [file] [log] [blame]
Test IndexedDB's cursor update.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
setVersionSuccess():
trans = event.target.transaction
PASS trans is non-null.
Deleted all object stores.
objectStore = db.createObjectStore('basicStore')
objectStore.add('myValue1', 'myKey1').onerror = unexpectedErrorCallback
objectStore.add('myValue2', 'myKey2').onerror = unexpectedErrorCallback
objectStore.add('myValue3', 'myKey3').onerror = unexpectedErrorCallback
objectStore.add('myValue4', 'myKey4').onerror = unexpectedErrorCallback
objectStore = db.createObjectStore('autoIncrementStore', {autoIncrement: true})
objectStore.add('foo1').onerror = unexpectedErrorCallback
objectStore.add('foo2').onerror = unexpectedErrorCallback
objectStore.add('foo3').onerror = unexpectedErrorCallback
objectStore.add('foo4').onerror = unexpectedErrorCallback
objectStore = db.createObjectStore('keyPathStore', {keyPath: 'id'})
objectStore.createIndex('numberIndex', 'number')
objectStore.add({number: 1, id: 1}).onerror = unexpectedErrorCallback
objectStore.add({number: 2, id: 2}).onerror = unexpectedErrorCallback
objectStore.add({number: 3, id: 3}).onerror = unexpectedErrorCallback
objectStore.add({number: 4, id: 4}).onerror = unexpectedErrorCallback
openBasicCursor()
trans = db.transaction(['basicStore', 'autoIncrementStore', 'keyPathStore'], 'readwrite')
trans.objectStore('basicStore')
objectStore.openCursor(keyRange)
basicUpdateCursor()
PASS event.target.source is objectStore
event.target.result.update('myUpdatedValue' + counter++)
event.target.source.continue()
basicUpdateCursor()
PASS event.target.source is objectStore
event.target.result.update('myUpdatedValue' + counter++)
event.target.source.continue()
basicUpdateCursor()
PASS event.target.source is objectStore
event.target.result.update('myUpdatedValue' + counter++)
event.target.source.continue()
basicUpdateCursor()
PASS event.target.source is objectStore
event.target.result.update('myUpdatedValue' + counter++)
event.target.source.continue()
basicUpdateCursor()
PASS event.target.source is objectStore
PASS counter is 5
trans.objectStore('basicStore').openCursor(keyRange)
basicCheckCursor()
PASS event.target.result.key is "myKey1"
PASS event.target.result.value is "myUpdatedValue1"
event.target.result.continue()
basicCheckCursor()
PASS event.target.result.key is "myKey2"
PASS event.target.result.value is "myUpdatedValue2"
event.target.result.continue()
basicCheckCursor()
PASS event.target.result.key is "myKey3"
PASS event.target.result.value is "myUpdatedValue3"
event.target.result.continue()
basicCheckCursor()
PASS event.target.result.key is "myKey4"
PASS event.target.result.value is "myUpdatedValue4"
event.target.result.continue()
basicCheckCursor()
PASS counter is 5
trans.objectStore('autoIncrementStore').openCursor(keyRange)
autoIncrementUpdateCursor()
event.target.result.update('myUpdatedFoo' + counter++)
event.target.source.continue()
autoIncrementUpdateCursor()
event.target.result.update('myUpdatedFoo' + counter++)
event.target.source.continue()
autoIncrementUpdateCursor()
event.target.result.update('myUpdatedFoo' + counter++)
event.target.source.continue()
autoIncrementUpdateCursor()
event.target.result.update('myUpdatedFoo' + counter++)
event.target.source.continue()
autoIncrementUpdateCursor()
PASS counter is 5
trans.objectStore('autoIncrementStore').openCursor(keyRange)
autoIncrementCheckCursor()
PASS event.target.result.key is counter
PASS event.target.result.value is "myUpdatedFoo1"
event.target.result.continue()
autoIncrementCheckCursor()
PASS event.target.result.key is counter
PASS event.target.result.value is "myUpdatedFoo2"
event.target.result.continue()
autoIncrementCheckCursor()
PASS event.target.result.key is counter
PASS event.target.result.value is "myUpdatedFoo3"
event.target.result.continue()
autoIncrementCheckCursor()
PASS event.target.result.key is counter
PASS event.target.result.value is "myUpdatedFoo4"
event.target.result.continue()
autoIncrementCheckCursor()
PASS counter is 5
trans.objectStore('keyPathStore').openCursor(keyRange)
keyPathUpdateCursor()
Expecting exception from event.target.result.update({id: 100 + counter, number: 100 + counter})
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.
event.target.result.update({id: counter, number: 100 + counter++})
event.target.source.continue()
keyPathUpdateCursor()
Expecting exception from event.target.result.update({id: 100 + counter, number: 100 + counter})
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.
event.target.result.update({id: counter, number: 100 + counter++})
event.target.source.continue()
keyPathUpdateCursor()
Expecting exception from event.target.result.update({id: 100 + counter, number: 100 + counter})
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.
event.target.result.update({id: counter, number: 100 + counter++})
event.target.source.continue()
keyPathUpdateCursor()
Expecting exception from event.target.result.update({id: 100 + counter, number: 100 + counter})
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.
event.target.result.update({id: counter, number: 100 + counter++})
event.target.source.continue()
keyPathUpdateCursor()
PASS counter is 5
trans.objectStore('keyPathStore').openCursor(keyRange)
keyPathCheckCursor()
PASS event.target.result.key is counter
PASS event.target.result.value.id is counter
PASS event.target.result.value.number is 101
event.target.result.continue()
keyPathCheckCursor()
PASS event.target.result.key is counter
PASS event.target.result.value.id is counter
PASS event.target.result.value.number is 102
event.target.result.continue()
keyPathCheckCursor()
PASS event.target.result.key is counter
PASS event.target.result.value.id is counter
PASS event.target.result.value.number is 103
event.target.result.continue()
keyPathCheckCursor()
PASS event.target.result.key is counter
PASS event.target.result.value.id is counter
PASS event.target.result.value.number is 104
event.target.result.continue()
keyPathCheckCursor()
PASS counter is 5
trans.objectStore('keyPathStore').index('numberIndex').openKeyCursor(keyRange)
keyCursor()
PASS event.target.result.key is counter + 100
PASS event.target.result.primaryKey is counter
Expecting exception from event.target.result.update({id: counter, number: counter + 200})
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
Exception message: Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor.
event.target.result.continue();
keyCursor()
PASS event.target.result.key is counter + 100
PASS event.target.result.primaryKey is counter
Expecting exception from event.target.result.update({id: counter, number: counter + 200})
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
Exception message: Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor.
event.target.result.continue();
keyCursor()
PASS event.target.result.key is counter + 100
PASS event.target.result.primaryKey is counter
Expecting exception from event.target.result.update({id: counter, number: counter + 200})
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
Exception message: Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor.
event.target.result.continue();
keyCursor()
PASS event.target.result.key is counter + 100
PASS event.target.result.primaryKey is counter
Expecting exception from event.target.result.update({id: counter, number: counter + 200})
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
Exception message: Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor.
event.target.result.continue();
keyCursor()
PASS counter is 5
openBasicCursor()
trans = db.transaction('basicStore')
trans.objectStore('basicStore')
objectStore.openCursor(keyRange)
attemptUpdate()
Expecting exception from cursor.update('myUpdatedValue')
PASS Exception was thrown.
PASS code is 0
PASS ename is 'ReadOnlyError'
Exception message: Failed to execute 'update' on 'IDBCursor': The record may not be updated inside a read-only transaction.
cursor.continue()
attemptUpdate()
Expecting exception from cursor.update('myUpdatedValue')
PASS Exception was thrown.
PASS code is 0
PASS ename is 'ReadOnlyError'
Exception message: Failed to execute 'update' on 'IDBCursor': The record may not be updated inside a read-only transaction.
cursor.continue()
attemptUpdate()
Expecting exception from cursor.update('myUpdatedValue')
PASS Exception was thrown.
PASS code is 0
PASS ename is 'ReadOnlyError'
Exception message: Failed to execute 'update' on 'IDBCursor': The record may not be updated inside a read-only transaction.
cursor.continue()
attemptUpdate()
Expecting exception from cursor.update('myUpdatedValue')
PASS Exception was thrown.
PASS code is 0
PASS ename is 'ReadOnlyError'
Exception message: Failed to execute 'update' on 'IDBCursor': The record may not be updated inside a read-only transaction.
cursor.continue()
attemptUpdate()
transactionComplete()
PASS successfullyParsed is true
TEST COMPLETE