1 <html> 2 <head> 3 <script> 4 5 function log(message) 6 { 7 document.body.innerHTML += message + "<br>"; 8 } 9 10 function GC() 11 { 12 // Force GC. 13 if (window.GCController) 14 GCController.collect(); 15 else { 16 for (var i = 0; i < 10000; ++i) { 17 ({ }); 18 } 19 } 20 } 21 22 // Variable for the database that will never be forgotten 23 var persistentDB = 0; 24 // Variable for the forgotten database 25 var forgottenDB = 0; 26 27 var completed = 0; 28 function checkCompletion() 29 { 30 if (++completed == 2 && window.layoutTestController) 31 layoutTestController.notifyDone(); 32 } 33 34 function runTest() 35 { 36 if (window.layoutTestController) { 37 layoutTestController.dumpAsText(); 38 layoutTestController.waitUntilDone(); 39 } 40 41 persistentDB = openDatabase("MultipleDatabasesTest1", "1.0", "Test one out of a set of databases being destroyed (1)", 32768); 42 forgottenDB = openDatabase("MultipleDatabasesTest2", "1.0", "Test one out of a set of databases being destroyed (2)", 32768); 43 44 persistentDB.transaction(function(tx) { 45 tx.executeSql("CREATE TABLE IF NOT EXISTS DataTest (randomData)", [], function(tx, result) { 46 for (var i = 0; i < 25; ++i) 47 tx.executeSql("INSERT INTO DataTest (randomData) VALUES (1)", []); 48 }); 49 }, function(err) { 50 log("Persistent Database Transaction Errored - " + err); 51 checkCompletion(); 52 }, function() { 53 log("Persistent Database Transaction Complete"); 54 checkCompletion(); 55 }); 56 57 forgottenDB.transaction(function(tx) { 58 tx.executeSql("CREATE TABLE IF NOT EXISTS EmptyTable (unimportantData)", []); 59 }, function(err) { 60 log("Forgotten Database Transaction Errored - " + err); 61 forgottenDB = 0; 62 GC(); 63 checkCompletion(); 64 }, function() { 65 log("Forgotten Database Transaction Complete"); 66 forgottenDB = 0; 67 GC(); 68 checkCompletion(); 69 }); 70 } 71 72 </script> 73 <body onload="runTest();"> 74 This test opens two databases, queues up a series of operations on both, then "forgets" about one of them. 75 After forcing GC, resources associated with that database should be freed gracefully.<br> 76 </body> 77 </html> 78