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 var testDate = new Date("February 24, 1955 12:00:00"); | 5 var testDate = new Date("February 24, 1955 12:00:00"); |
6 | 6 |
7 function getByDateSuccess() | 7 function getByDateSuccess() |
8 { | 8 { |
9 debug('Data retrieved by date key'); | 9 debug('Data retrieved by date key'); |
10 | 10 |
11 shouldBe("event.result", "'foo'"); | 11 shouldBe("event.result", "'foo'"); |
12 done(); | 12 done(); |
13 } | 13 } |
14 | 14 |
15 function recordNotFound() | 15 function recordNotFound() |
16 { | 16 { |
17 debug('Removed data can no longer be found'); | 17 debug('Removed data can no longer be found'); |
| 18 shouldBe("event.result", "undefined"); |
18 | 19 |
19 debug('Retrieving an index'); | 20 debug('Retrieving an index'); |
20 shouldBe("objectStore.index('fname_index').name", "'fname_index'"); | 21 shouldBe("objectStore.index('fname_index').name", "'fname_index'"); |
21 | 22 |
22 debug('Removing an index'); | 23 debug('Removing an index'); |
23 try { | 24 try { |
24 objectStore.deleteIndex('fname_index'); | 25 objectStore.deleteIndex('fname_index'); |
25 } catch(e) { | 26 } catch(e) { |
26 fail(e); | 27 fail(e); |
27 } | 28 } |
28 | 29 |
29 var result = transaction.objectStore('stuff').get(testDate); | 30 var result = transaction.objectStore('stuff').get(testDate); |
30 result.onsuccess = getByDateSuccess; | 31 result.onsuccess = getByDateSuccess; |
31 result.onerror = unexpectedErrorCallback; | 32 result.onerror = unexpectedErrorCallback; |
32 } | 33 } |
33 | 34 |
34 function removeSuccess() | 35 function removeSuccess() |
35 { | 36 { |
36 debug('Data removed'); | 37 debug('Data removed'); |
37 | 38 |
38 var result = objectStore.get(1); | 39 var result = objectStore.get(1); |
39 result.onsuccess = unexpectedSuccessCallback; | 40 result.onsuccess = recordNotFound; |
40 result.onerror = recordNotFound; | 41 result.onerror = unexpectedSuccessCallback; |
41 } | 42 } |
42 | 43 |
43 function getSuccess() | 44 function getSuccess() |
44 { | 45 { |
45 debug('Data retrieved'); | 46 debug('Data retrieved'); |
46 | 47 |
47 shouldBe("event.result.fname", "'John'"); | 48 shouldBe("event.result.fname", "'John'"); |
48 shouldBe("event.result.lname", "'Doe'"); | 49 shouldBe("event.result.lname", "'Doe'"); |
49 shouldBe("event.result.id", "1"); | 50 shouldBe("event.result.id", "1"); |
50 | 51 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 result.onerror = unexpectedErrorCallback; | 113 result.onerror = unexpectedErrorCallback; |
113 } | 114 } |
114 | 115 |
115 function test() | 116 function test() |
116 { | 117 { |
117 debug('Connecting to indexedDB'); | 118 debug('Connecting to indexedDB'); |
118 var result = webkitIndexedDB.open('name'); | 119 var result = webkitIndexedDB.open('name'); |
119 result.onsuccess = setVersion; | 120 result.onsuccess = setVersion; |
120 result.onerror = unexpectedErrorCallback; | 121 result.onerror = unexpectedErrorCallback; |
121 } | 122 } |
OLD | NEW |