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 function test() { | 5 function test() { |
6 request = webkitIndexedDB.open('database-basics'); | 6 request = webkitIndexedDB.open('database-basics'); |
7 request.onupgradeneeded = upgradeNeeded; | 7 request.onupgradeneeded = upgradeNeeded; |
8 request.onsuccess = onSuccess; | 8 request.onsuccess = onSuccess; |
9 request.onerror = unexpectedErrorCallback; | 9 request.onerror = unexpectedErrorCallback; |
10 request.onblocked = unexpectedBlockedCallback; | 10 request.onblocked = unexpectedBlockedCallback; |
11 } | 11 } |
12 | 12 |
13 var gotUpgradeNeeded = false; | 13 var gotUpgradeNeeded = false; |
14 function upgradeNeeded() { | 14 function upgradeNeeded(evt) { |
| 15 event = evt; |
| 16 shouldBe("event.dataLoss", "'total'"); |
15 gotUpgradeNeeded = true; | 17 gotUpgradeNeeded = true; |
16 } | 18 } |
17 | 19 |
18 function onSuccess(event) { | 20 function onSuccess(event) { |
19 db = event.target.result; | 21 db = event.target.result; |
20 debug("The pre-existing leveldb has an objectStore in 'database-basics',"); | 22 debug("The pre-existing leveldb has an objectStore in 'database-basics',"); |
21 debug("ensure that it was blown away"); | 23 debug("ensure that it was blown away"); |
22 shouldBe("db.objectStoreNames.length", "0"); | 24 shouldBe("db.objectStoreNames.length", "0"); |
23 debug("We should have gotten an upgradeneeded event because the new empty"); | 25 debug("We should have gotten an upgradeneeded event because the new empty"); |
24 debug("database doesn't have a version."); | 26 debug("database doesn't have a version."); |
25 shouldBeTrue("gotUpgradeNeeded"); | 27 shouldBeTrue("gotUpgradeNeeded"); |
26 done(); | 28 done(); |
27 } | 29 } |
OLD | NEW |