2 <script src=
"../../resources/js-test.js"></script>
3 <script src=
"resources/shared.js"></script>
6 description('webkitGetDatabaseNames should only return successfully created databases');
8 function deleteDatabase(dbname
)
10 return new Promise(function(resolve
, reject
) {
11 var request
= indexedDB
.deleteDatabase(dbname
);
12 request
.onsuccess = function() {
13 resolve(request
.result
);
15 request
.onerror = function() {
16 reject(request
.error
);
21 function getDatabaseNames()
23 return new Promise(function(resolve
, reject
) {
24 var request
= indexedDB
.webkitGetDatabaseNames();
25 request
.onsuccess = function() {
26 resolve(request
.result
);
28 request
.onerror = function() {
29 reject(request
.error
);
34 function openDatabaseAndAbortUpgrade(dbname
)
36 return new Promise(function(resolve
, reject
) {
37 var request
= indexedDB
.open(dbname
, 1);
38 request
.onupgradeneeded = function() {
39 request
.transaction
.abort();
41 request
.onsuccess = function() {
42 reject(new Error('Open should not succeed'));
44 request
.onerror = function() {
51 deleteDatabase(dbname
)
52 .then(getDatabaseNames
)
53 .then(function(names
) {
54 if (names
.contains(dbname
))
55 throw Error('Database should have been deleted if present');
57 return openDatabaseAndAbortUpgrade(dbname
);
59 .then(getDatabaseNames
)
60 .then(function(names
) {
61 if (names
.contains(dbname
))
62 throw Error('Database name should not be present');
64 testPassed('Database name was not present');
67 .catch(function(reason
) {
68 testFailed(reason
.name
+ ': ' + reason
.message
);