93 lines
2.7 KiB
Plaintext
93 lines
2.7 KiB
Plaintext
Test IndexedDB's IDBObjectStore.get(IDBKeyRange) method.
|
|
|
|
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)
|
|
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: Provided data is inadequate.
|
|
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: Provided data is inadequate.
|
|
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: Provided data is inadequate.
|
|
finishJSTest()
|
|
PASS successfullyParsed is true
|
|
|
|
TEST COMPLETE
|
|
|