1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test the basics of IndexedDB's IDBFactory.");
10 shouldBeEqualToString("typeof indexedDB.open", "function");
11 shouldBeEqualToString("typeof indexedDB.cmp", "function");
12 shouldBeEqualToString("typeof indexedDB.deleteDatabase", "function");
14 // Non-standard, must be prefixed
15 shouldBeEqualToString("typeof indexedDB.webkitGetDatabaseNames", "function");
16 shouldBeEqualToString("typeof indexedDB.getDatabaseNames", "undefined");
18 name = 'storage/indexeddb/factory-basics';
20 evalAndLog("request = indexedDB.webkitGetDatabaseNames()");
21 shouldBeNull("request.source");
22 request.onsuccess = getDatabaseNamesSuccess1;
23 request.onerror = unexpectedErrorCallback;
26 function getDatabaseNamesSuccess1(evt)
30 evalAndLog("databaseNames = event.target.result");
31 shouldBeFalse("databaseNames.contains('" + name + "')");
32 shouldBeFalse("databaseNames.contains('DATABASE THAT DOES NOT EXIST')");
34 evalAndLog("request = indexedDB.open(name)");
35 shouldBeNull("request.source");
36 request.onsuccess = openSuccess;
37 request.onerror = unexpectedErrorCallback;
40 function openSuccess(evt)
43 evalAndLog("event.target.result.close()");
44 request = evalAndLog("indexedDB.webkitGetDatabaseNames()");
45 request.onsuccess = getDatabaseNamesSuccess2;
46 request.onerror = unexpectedErrorCallback;
49 function getDatabaseNamesSuccess2(evt)
53 evalAndLog("databaseNames = event.target.result");
54 shouldBeTrue("databaseNames.contains('" + name + "')");
55 shouldBeFalse("databaseNames.contains('DATABASE THAT DOES NOT EXIST')");
57 evalAndLog("request = indexedDB.deleteDatabase('" + name + "')");
58 shouldBeNull("request.source");
59 request.onsuccess = deleteDatabaseSuccess;
60 request.onerror = unexpectedErrorCallback;
63 function deleteDatabaseSuccess()
65 request = evalAndLog("indexedDB.webkitGetDatabaseNames()");
66 request.onsuccess = getDatabaseNamesSuccess3;
67 request.onerror = unexpectedErrorCallback;
70 function getDatabaseNamesSuccess3(evt)
74 evalAndLog("databaseNames = event.target.result");
75 shouldBeFalse("databaseNames.contains('" + name + "')");
76 shouldBeFalse("databaseNames.contains('DATABASE THAT DOES NOT EXIST')");
78 request = evalAndLog("indexedDB.deleteDatabase('DATABASE THAT DOES NOT EXIST')");
79 request.onsuccess = deleteDatabaseSuccess2;
80 request.onerror = unexpectedErrorCallback;
83 function deleteDatabaseSuccess2()