OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 function emptyCursorSuccess() | 5 function emptyCursorSuccess() |
6 { | 6 { |
7 debug('Empty cursor opened successfully.') | 7 debug('Empty cursor opened successfully.') |
8 done(); | 8 done(); |
9 } | 9 } |
10 | 10 |
11 function openEmptyCursor() | 11 function openEmptyCursor() |
12 { | 12 { |
13 debug('Opening an empty cursor.'); | 13 debug('Opening an empty cursor.'); |
14 keyRange = webkitIDBKeyRange.lowerBound('InexistentKey'); | 14 keyRange = webkitIDBKeyRange.lowerBound('InexistentKey'); |
15 result = objectStore.openCursor({range: keyRange}); | 15 result = objectStore.openCursor(keyRange); |
16 result.onsuccess = emptyCursorSuccess; | 16 result.onsuccess = emptyCursorSuccess; |
17 result.onerror = unexpectedErrorCallback; | 17 result.onerror = unexpectedErrorCallback; |
18 } | 18 } |
19 | 19 |
20 function cursorSuccess() | 20 function cursorSuccess() |
21 { | 21 { |
22 var cursor = event.result; | 22 var cursor = event.result; |
23 if (cursor === null) { | 23 if (cursor === null) { |
24 debug('Cursor reached end of range.'); | 24 debug('Cursor reached end of range.'); |
25 openEmptyCursor(); | 25 openEmptyCursor(); |
26 return; | 26 return; |
27 } | 27 } |
28 | 28 |
29 debug('Cursor opened successfully.'); | 29 debug('Cursor opened successfully.'); |
30 shouldBe("event.result.direction", "0"); | 30 shouldBe("event.result.direction", "0"); |
31 shouldBe("event.result.key", "3.14"); | 31 shouldBe("event.result.key", "3.14"); |
32 shouldBe("event.result.value", "'myValue'"); | 32 shouldBe("event.result.value", "'myValue'"); |
33 | 33 |
34 cursor.continue(); | 34 cursor.continue(); |
35 } | 35 } |
36 | 36 |
37 function openCursor(objectStore) | 37 function openCursor(objectStore) |
38 { | 38 { |
39 debug('Opening cursor'); | 39 debug('Opening cursor'); |
40 var keyRange = webkitIDBKeyRange.lowerBound(3.12); | 40 var keyRange = webkitIDBKeyRange.lowerBound(3.12); |
41 var result = objectStore.openCursor({range: keyRange}); | 41 var result = objectStore.openCursor(keyRange); |
42 result.onsuccess = cursorSuccess; | 42 result.onsuccess = cursorSuccess; |
43 result.onerror = unexpectedErrorCallback; | 43 result.onerror = unexpectedErrorCallback; |
44 } | 44 } |
45 | 45 |
46 function dataAddedSuccess() | 46 function dataAddedSuccess() |
47 { | 47 { |
48 debug('Data added'); | 48 debug('Data added'); |
49 openCursor(objectStore); | 49 openCursor(objectStore); |
50 } | 50 } |
51 | 51 |
(...skipping 16 matching lines...) Expand all Loading... |
68 result.onerror = unexpectedErrorCallback; | 68 result.onerror = unexpectedErrorCallback; |
69 } | 69 } |
70 | 70 |
71 function test() | 71 function test() |
72 { | 72 { |
73 debug('Connecting to indexedDB'); | 73 debug('Connecting to indexedDB'); |
74 var result = webkitIndexedDB.open('name'); | 74 var result = webkitIndexedDB.open('name'); |
75 result.onsuccess = setVersion; | 75 result.onsuccess = setVersion; |
76 result.onerror = unexpectedErrorCallback; | 76 result.onerror = unexpectedErrorCallback; |
77 } | 77 } |
OLD | NEW |