4 Copyright 2014 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
9 <title>IDB test that db's corrupted while open are properly handled Part
2 /
2</title>
10 <script type=
"text/javascript" src=
"common.js"></script>
14 dbname
= "corrupted_open_db_detection.html";
15 request
= webkitIndexedDB
.open(dbname
);
16 request
.onupgradeneeded
= upgradeNeeded
;
17 request
.onsuccess
= onSuccess
;
18 request
.onerror
= unexpectedErrorCallback
;
19 request
.onblocked
= unexpectedBlockedCallback
;
22 var gotUpgradeNeeded
= false;
23 function upgradeNeeded(evt
) {
25 shouldBe("event.dataLoss", "'total'");
26 shouldBeTrue('event.dataLossMessage.startsWith("IndexedDB (database was corrupt): ")');
27 gotUpgradeNeeded
= true;
30 function onSuccess(event
) {
31 db
= event
.target
.result
;
32 debug("The pre-existing leveldb has an objectStore in 'database-basics',");
33 debug("ensure that it was blown away");
34 shouldBe("db.objectStoreNames.length", "0");
35 debug("We should have gotten an upgradeneeded event because the new empty");
36 debug("database doesn't have a version.");
37 shouldBeTrue("gotUpgradeNeeded");
43 <body onLoad=
"test()">
44 <div id=
"status">Starting...
</div>