OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 function cursorSuccess() | 6 function cursorSuccess() |
7 { | 7 { |
8 debug("Cursor opened successfully.") | 8 debug("Cursor opened successfully."); |
9 // FIXME: check that we can iterate the cursor. | 9 // FIXME: check that we can iterate the cursor. |
10 shouldBe("event.target.result.direction", "'next'"); | 10 shouldBe("event.target.result.direction", "'next'"); |
11 shouldBe("event.target.result.key", "'myKey' + count"); | 11 shouldBe("event.target.result.key", "'myKey' + count"); |
12 shouldBe("event.target.result.value.keyPath", "'myKey' + count"); | 12 shouldBe("event.target.result.value.keyPath", "'myKey' + count"); |
13 shouldBe("event.target.result.value.value", "'myValue' + count"); | 13 shouldBe("event.target.result.value.value", "'myValue' + count"); |
14 if (++count >= 5) | 14 if (++count >= 5) |
15 done(); | 15 done(); |
16 else | 16 else |
17 openCursor(); | 17 openCursor(); |
18 } | 18 } |
19 | 19 |
20 function openCursor() | 20 function openCursor() |
21 { | 21 { |
22 debug("Opening cursor #" + count); | 22 debug("Opening cursor #" + count); |
23 keyRange = webkitIDBKeyRange.lowerBound("myKey" + count); | 23 keyRange = IDBKeyRange.lowerBound("myKey" + count); |
24 request = objectStore.openCursor(keyRange); | 24 request = objectStore.openCursor(keyRange); |
25 request.onsuccess = cursorSuccess; | 25 request.onsuccess = cursorSuccess; |
26 request.onerror = unexpectedErrorCallback; | 26 request.onerror = unexpectedErrorCallback; |
27 } | 27 } |
28 | 28 |
29 function populateObjectStore() | 29 function populateObjectStore() |
30 { | 30 { |
31 debug("Populating object store #" + count); | 31 debug("Populating object store #" + count); |
32 obj = {'keyPath': 'myKey' + count, 'value': 'myValue' + count}; | 32 obj = {'keyPath': 'myKey' + count, 'value': 'myValue' + count}; |
33 request = objectStore.add(obj); | 33 request = objectStore.add(obj); |
(...skipping 12 matching lines...) Expand all Loading... |
46 db = event.target.result; | 46 db = event.target.result; |
47 window.objectStore = db.createObjectStore('test', {keyPath: 'keyPath'}); | 47 window.objectStore = db.createObjectStore('test', {keyPath: 'keyPath'}); |
48 count = 0; | 48 count = 0; |
49 populateObjectStore(); | 49 populateObjectStore(); |
50 } | 50 } |
51 | 51 |
52 function test() | 52 function test() |
53 { | 53 { |
54 indexedDBTest(createObjectStore); | 54 indexedDBTest(createObjectStore); |
55 } | 55 } |
OLD | NEW |