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 onCursor() | 5 function onCursor() |
6 { | 6 { |
7 var cursor = event.result; | 7 var cursor = event.result; |
8 if (cursor === null) { | 8 if (cursor === null) { |
9 debug('Reached end of object cursor.'); | 9 debug('Reached end of object cursor.'); |
10 if (!gotObjectThroughCursor) { | 10 if (!gotObjectThroughCursor) { |
(...skipping 15 matching lines...) Expand all Loading... |
26 function onKeyCursor() | 26 function onKeyCursor() |
27 { | 27 { |
28 var cursor = event.result; | 28 var cursor = event.result; |
29 if (cursor === null) { | 29 if (cursor === null) { |
30 debug('Reached end of key cursor.'); | 30 debug('Reached end of key cursor.'); |
31 if (!gotKeyThroughCursor) { | 31 if (!gotKeyThroughCursor) { |
32 fail('Did not get key through cursor.'); | 32 fail('Did not get key through cursor.'); |
33 return; | 33 return; |
34 } | 34 } |
35 | 35 |
36 var result = index.openCursor({range: IDBKeyRange.only(55)}); | 36 var result = index.openCursor(IDBKeyRange.only(55)); |
37 result.onsuccess = onCursor; | 37 result.onsuccess = onCursor; |
38 result.onerror = unexpectedErrorCallback; | 38 result.onerror = unexpectedErrorCallback; |
39 gotObjectThroughCursor = false; | 39 gotObjectThroughCursor = false; |
40 return; | 40 return; |
41 } | 41 } |
42 | 42 |
43 debug('Got key through cursor.'); | 43 debug('Got key through cursor.'); |
44 shouldBe('event.result.key', '55'); | 44 shouldBe('event.result.key', '55'); |
45 shouldBe('event.result.value', '1'); | 45 shouldBe('event.result.value', '1'); |
46 gotKeyThroughCursor = true; | 46 gotKeyThroughCursor = true; |
47 | 47 |
48 cursor.continue(); | 48 cursor.continue(); |
49 } | 49 } |
50 | 50 |
51 function getSuccess() | 51 function getSuccess() |
52 { | 52 { |
53 debug('Successfully got object through key in index.'); | 53 debug('Successfully got object through key in index.'); |
54 | 54 |
55 shouldBe('event.result.aKey', '55'); | 55 shouldBe('event.result.aKey', '55'); |
56 shouldBe('event.result.aValue', '"foo"'); | 56 shouldBe('event.result.aValue', '"foo"'); |
57 | 57 |
58 var result = index.openKeyCursor({range: IDBKeyRange.only(55)}); | 58 var result = index.openKeyCursor(IDBKeyRange.only(55)); |
59 result.onsuccess = onKeyCursor; | 59 result.onsuccess = onKeyCursor; |
60 result.onerror = unexpectedErrorCallback; | 60 result.onerror = unexpectedErrorCallback; |
61 gotKeyThroughCursor = false; | 61 gotKeyThroughCursor = false; |
62 } | 62 } |
63 | 63 |
64 function getKeySuccess() | 64 function getKeySuccess() |
65 { | 65 { |
66 debug('Successfully got key.'); | 66 debug('Successfully got key.'); |
67 shouldBe('event.result', '1'); | 67 shouldBe('event.result', '1'); |
68 | 68 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 IDBCursor = webkitIDBCursor; | 151 IDBCursor = webkitIDBCursor; |
152 IDBKeyRange = webkitIDBKeyRange; | 152 IDBKeyRange = webkitIDBKeyRange; |
153 IDBTransaction = webkitIDBTransaction; | 153 IDBTransaction = webkitIDBTransaction; |
154 } | 154 } |
155 | 155 |
156 debug('Connecting to indexedDB'); | 156 debug('Connecting to indexedDB'); |
157 var result = indexedDB.open('name'); | 157 var result = indexedDB.open('name'); |
158 result.onsuccess = setVersion; | 158 result.onsuccess = setVersion; |
159 result.onerror = unexpectedErrorCallback; | 159 result.onerror = unexpectedErrorCallback; |
160 } | 160 } |
OLD | NEW |