blob: ef7017f08193491ddcba72b7de29ba29d169682f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for proper listing indexedDB databases with no object stores</title>
</head>
<body>
<script type="application/javascript;version=1.7">
let db;
window.setup = function* () {
db = yield new Promise((resolve, reject) => {
let request = indexedDB.open("idb", 1);
request.onsuccess = e => resolve(e.target.result);
request.onerror = e => reject(new Error("error opening db connection"));
request.onupgradeneeded = e => {
let db = e.target.result;
let store = db.createObjectStore("obj", { keyPath: "id" });
};
});
dump("opened indexedDB\n");
};
window.closeDb = function* () {
db.close();
};
window.deleteDb = function* () {
yield new Promise((resolve, reject) => {
let request = indexedDB.deleteDatabase("idb");
request.onsuccess = resolve;
request.onerror = e => reject(new Error("error deleting db"));
});
};
window.clear = function* () {
for (let dbName of ["idb1", "idb2"]) {
yield new Promise(resolve => {
indexedDB.deleteDatabase(dbName).onsuccess = resolve;
});
}
dump("removed indexedDB items from main page\n");
};
</script>
</body>
</html>
|