blob: 04f0fd18066e29c5f5b429e05668bfd0bf04c2d9 [file] [log] [blame]
Test IndexedDB's IDBCursor.continue() with a primary key parameter.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
dbname = "cursor-continueprimarykey.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
prepareDatabase():
db = event.target.result
store = db.createObjectStore('store')
index = store.createIndex('index', 'indexKey', {multiEntry: true})
store.put({indexKey: ['a', 'b']}, 1)
store.put({indexKey: ['a', 'b']}, 2)
store.put({indexKey: ['a', 'b']}, 3)
store.put({indexKey: ['b']}, 4)
checking index structure...
index key primary key
========= ===========
a 1
a 2
a 3
b 1
b 2
b 3
b 4
Test case: cursor.continue()
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continue()
PASS cursor.key is "a"
PASS cursor.primaryKey is 2
Test case: cursor.continue('a')
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
Expecting exception from cursor.continue('a')
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'continue' on 'IDBCursor': The parameter is less than or equal to this cursor's position.
Test case: cursor.continue('b')
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continue('b')
PASS cursor.key is "b"
PASS cursor.primaryKey is 1
Test case: cursor.continue('c')
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continue('c')
PASS cursor is null
Test case: cursor.continuePrimaryKey('a', 3)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continuePrimaryKey('a', 3)
PASS cursor.key is "a"
PASS cursor.primaryKey is 3
Test case: cursor.continuePrimaryKey('a', 4)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continuePrimaryKey('a', 4)
PASS cursor.key is "b"
PASS cursor.primaryKey is 1
Test case: cursor.continuePrimaryKey('b', 1)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continuePrimaryKey('b', 1)
PASS cursor.key is "b"
PASS cursor.primaryKey is 1
Test case: cursor.continuePrimaryKey('b', 4)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continuePrimaryKey('b', 4)
PASS cursor.key is "b"
PASS cursor.primaryKey is 4
Test case: cursor.continuePrimaryKey('b', 5)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continuePrimaryKey('b', 5)
PASS cursor is null
Test case: cursor.continuePrimaryKey('c', 1)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
cursor.continuePrimaryKey('c', 1)
PASS cursor is null
Test case: cursor.continuePrimaryKey(null, 1)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
Expecting exception from cursor.continuePrimaryKey(null, 1)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'continuePrimaryKey' on 'IDBCursor': The parameter is not a valid key.
Test case: cursor.continuePrimaryKey(null, 2)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
Expecting exception from cursor.continuePrimaryKey(null, 2)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'continuePrimaryKey' on 'IDBCursor': The parameter is not a valid key.
Test case: cursor.continuePrimaryKey(null, 3)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
Expecting exception from cursor.continuePrimaryKey(null, 3)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'continuePrimaryKey' on 'IDBCursor': The parameter is not a valid key.
Test case: cursor.continuePrimaryKey(null, 4)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
Expecting exception from cursor.continuePrimaryKey(null, 4)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'continuePrimaryKey' on 'IDBCursor': The parameter is not a valid key.
Test case: cursor.continuePrimaryKey(null, 5)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
Expecting exception from cursor.continuePrimaryKey(null, 5)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'continuePrimaryKey' on 'IDBCursor': The parameter is not a valid key.
Test case: cursor.continuePrimaryKey('a', null)
tx = db.transaction('store')
request = tx.objectStore('store').index('index').openCursor()
Expecting exception from cursor.continuePrimaryKey('a', null)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'continuePrimaryKey' on 'IDBCursor': The parameter is not a valid key.
PASS successfullyParsed is true
TEST COMPLETE