1 Test IndexedDB's IDBObjectStore.get(IDBKeyRange) method.
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "get-keyrange.html"
7 indexedDB.deleteDatabase(dbname)
9 db.createObjectStore('someObjectStore')
10 objectStore.createIndex('someIndex', 'x')
11 objectStore.add({'x': 0 }, 0)
12 objectStore.add({'x': 1 }, 1)
13 objectStore.add({'x': 2 }, 2)
14 objectStore.add({'x': 3 }, 3)
15 objectStore.add({'x': 4 }, 4)
16 objectStore.add({'x': 5 }, 5)
17 objectStore.add({'x': 6 }, 6)
18 objectStore.add({'x': 7 }, 7)
19 objectStore.add({'x': 8 }, 8)
20 objectStore.add({'x': 9 }, 9)
22 objectStore.get(IDBKeyRange.only(3))
24 objectStore.get(IDBKeyRange.lowerBound(5))
26 objectStore.get(IDBKeyRange.lowerBound(5, true))
28 objectStore.get(IDBKeyRange.upperBound(7))
30 objectStore.get(IDBKeyRange.upperBound(7, true))
32 objectStore.get(IDBKeyRange.lowerBound(2.5))
34 objectStore.get(IDBKeyRange.lowerBound(100))
35 PASS result is undefined
36 objectStore.get(IDBKeyRange.only(3.3))
37 PASS result is undefined
38 Expecting exception from objectStore.get(null)
39 PASS Exception was thrown.
41 PASS ename is 'DataError'
42 Exception message: Failed to execute 'get' on 'IDBObjectStore': No key or key range specified.
44 index.get(IDBKeyRange.only(3))
46 index.get(IDBKeyRange.lowerBound(5))
48 index.get(IDBKeyRange.lowerBound(5, true))
50 index.get(IDBKeyRange.upperBound(7))
52 index.get(IDBKeyRange.upperBound(7, true))
54 index.get(IDBKeyRange.lowerBound(2.5))
56 index.get(IDBKeyRange.lowerBound(100))
57 PASS result is undefined
58 index.get(IDBKeyRange.only(3.3))
59 PASS result is undefined
60 Expecting exception from index.get(null)
61 PASS Exception was thrown.
63 PASS ename is 'DataError'
64 Exception message: Failed to execute 'get' on 'IDBIndex': No key or key range specified.
66 index.getKey(IDBKeyRange.only(3))
68 index.getKey(IDBKeyRange.lowerBound(5))
70 index.getKey(IDBKeyRange.lowerBound(5, true))
72 index.getKey(IDBKeyRange.upperBound(7))
74 index.getKey(IDBKeyRange.upperBound(7, true))
76 index.getKey(IDBKeyRange.lowerBound(2.5))
78 index.getKey(IDBKeyRange.lowerBound(100))
79 PASS result is undefined
80 index.getKey(IDBKeyRange.only(3.3))
81 PASS result is undefined
82 Expecting exception from index.getKey(null)
83 PASS Exception was thrown.
85 PASS ename is 'DataError'
86 Exception message: Failed to execute 'getKey' on 'IDBIndex': No key or key range specified.
88 PASS successfullyParsed is true