1 <html> 2 <head> 3 <script> 4 function log(message) 5 { 6 document.getElementById("console").innerHTML += message + "<br>"; 7 } 8 9 function finishTest() 10 { 11 log("Test part 1 Complete"); 12 if (window.layoutTestController) 13 layoutTestController.notifyDone(); 14 } 15 16 function errorFunction(error) 17 { 18 log("Test failed - " + error.message); 19 finishTest(); 20 } 21 22 function addData(db) 23 { 24 db.transaction(function(tx) { 25 log("Inserting some data"); 26 // Load a new page while the transaction is still in progress, interrupting the transaction. 27 // This should not leave the database locked and on the next page we should be able to insert 28 // some more data. 29 tx.executeSql("INSERT INTO DataTest (testData) VALUES (ZEROBLOB(524200))", [], 30 function(tx, result) { location.href = "./resources/database-lock-after-reload-2.html"; }, 31 function(tx, error) { errorFunction(error); }); 32 tx.executeSql("INSERT INTO DataTest (testData) VALUES (ZEROBLOB(524200))"); 33 }, errorFunction, function() { finishTest(); }); 34 } 35 36 function runTest() 37 { 38 if (window.layoutTestController) { 39 layoutTestController.clearAllDatabases(); 40 layoutTestController.dumpAsText(); 41 layoutTestController.waitUntilDone(); 42 } 43 44 var database; 45 try { 46 database = openDatabase("DatabaseLockTest", "1.0", "Test for database locking", 5242880); 47 } catch (e) { 48 log("Error - could not open database"); 49 finishTest(); 50 } 51 52 database.transaction(function(tx) { 53 log("Adding a table"); 54 tx.executeSql("CREATE TABLE DataTest (testData)", [], function(tx, result) { }, 55 function(tx, error) { errorFunction(error); }); 56 }, errorFunction, function() { addData(database); }); 57 } 58 59 </script> 60 </head> 61 62 <body onload="runTest()"> 63 <pre id="console"> 64 </pre> 65 </body> 66 67 </html> 68