blob: 8894b5821645ca0b83d08df7b356fb95f771f87e [file] [log] [blame]
Test IndexedDB's IDBObjectStore.get(IDBKeyRange) method.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
dbname = "get-keyrange.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
db.createObjectStore('someObjectStore')
objectStore.createIndex('someIndex', 'x')
objectStore.add({'x': 0 }, 0)
objectStore.add({'x': 1 }, 1)
objectStore.add({'x': 2 }, 2)
objectStore.add({'x': 3 }, 3)
objectStore.add({'x': 4 }, 4)
objectStore.add({'x': 5 }, 5)
objectStore.add({'x': 6 }, 6)
objectStore.add({'x': 7 }, 7)
objectStore.add({'x': 8 }, 8)
objectStore.add({'x': 9 }, 9)
runObjStoreTests()
objectStore.get(IDBKeyRange.only(3))
PASS result.x is 3
objectStore.get(IDBKeyRange.lowerBound(5))
PASS result.x is 5
objectStore.get(IDBKeyRange.lowerBound(5, true))
PASS result.x is 6
objectStore.get(IDBKeyRange.upperBound(7))
PASS result.x is 0
objectStore.get(IDBKeyRange.upperBound(7, true))
PASS result.x is 0
objectStore.get(IDBKeyRange.lowerBound(2.5))
PASS result.x is 3
objectStore.get(IDBKeyRange.lowerBound(100))
PASS result is undefined
objectStore.get(IDBKeyRange.only(3.3))
PASS result is undefined
Expecting exception from objectStore.get(null)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
runIndexStoreTests()
index.get(IDBKeyRange.only(3))
PASS result.x is 3
index.get(IDBKeyRange.lowerBound(5))
PASS result.x is 5
index.get(IDBKeyRange.lowerBound(5, true))
PASS result.x is 6
index.get(IDBKeyRange.upperBound(7))
PASS result.x is 0
index.get(IDBKeyRange.upperBound(7, true))
PASS result.x is 0
index.get(IDBKeyRange.lowerBound(2.5))
PASS result.x is 3
index.get(IDBKeyRange.lowerBound(100))
PASS result is undefined
index.get(IDBKeyRange.only(3.3))
PASS result is undefined
Expecting exception from index.get(null)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'get' on 'IDBIndex': No key or key range specified.
runIndexKeyTests()
index.getKey(IDBKeyRange.only(3))
PASS result is 3
index.getKey(IDBKeyRange.lowerBound(5))
PASS result is 5
index.getKey(IDBKeyRange.lowerBound(5, true))
PASS result is 6
index.getKey(IDBKeyRange.upperBound(7))
PASS result is 0
index.getKey(IDBKeyRange.upperBound(7, true))
PASS result is 0
index.getKey(IDBKeyRange.lowerBound(2.5))
PASS result is 3
index.getKey(IDBKeyRange.lowerBound(100))
PASS result is undefined
index.getKey(IDBKeyRange.only(3.3))
PASS result is undefined
Expecting exception from index.getKey(null)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'getKey' on 'IDBIndex': No key or key range specified.
finishJSTest()
PASS successfullyParsed is true
TEST COMPLETE