6 document
.getElementById("console").innerHTML
+= message
+ "<br>";
11 if (window
.testRunner
)
12 testRunner
.notifyDone();
17 if (window
.testRunner
) {
18 testRunner
.clearAllDatabases();
19 testRunner
.setDatabaseQuota(32768);
20 testRunner
.dumpDatabaseCallbacks();
21 testRunner
.dumpAsText();
22 testRunner
.waitUntilDone();
25 var transactionsRun
= 0;
27 // Open a new database with a creation callback, and make sure the creation callback is queued
28 var creationCallbackCalled1
= false;
29 var db1Name
= "OpenDatabaseCreationCallback1" + (new Date()).getTime();
30 var db1
= openDatabase(db1Name
, "1.0", "", 1,
32 creationCallbackCalled1
= true;
33 if (db
.version
!= "") {
34 log("Creation callback was called with a database with version " +
35 db
.version
+ "; empty string expected.");
40 // Putting this code inside a transaction on 'db1' makes sure that it is executed after
41 // the creation callback is.
42 db1
.transaction(function(tx
) {
43 if (!creationCallbackCalled1
) {
44 log("Creation callback for db1 was not called.");
47 if (++transactionsRun
== 2)
51 // Try to open another handle to the same database.
52 // Since the version of this database is "" (empty string), openDatabase() should return
53 // a null handle and throw a INVALID_STATE_ERR exception.
56 db1Fail
= openDatabase(db1Name
, "1.0", "", 1);
57 log("This statement should not have been executed; an INVALID_STATE_ERR exception should've been thrown.");
61 log("db1Fail should have been null.");
66 // Open a handle to another database, first without a creation callback, then with one.
67 // Make sure the creation callback is not called.
68 var creationCallbackCalled2
= false;
69 var db2
= openDatabase("OpenDatabaseCreationCallback2", "1.0", "", 1);
70 db2
= openDatabase("OpenDatabaseCreationCallback2", "1.0", "", 1,
71 function(db
) { creationCallbackCalled2
= true; });
72 db2
.transaction(function(tx
) {
73 if (creationCallbackCalled2
) {
74 log("Creation callback for db2 should not have been called.");
77 if (++transactionsRun
== 2)
85 <body onload=
"runTest()">
86 This test tests openDatabase()'s creation callback.