| <html> |
| <head> |
| <script> |
| function log(message) |
| { |
| document.getElementById("console").innerHTML += message + "<br>"; |
| } |
| |
| function finishTest() |
| { |
| log("Test part 1 Complete"); |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| |
| function errorFunction(error) |
| { |
| log("Test failed - " + error.message); |
| finishTest(); |
| } |
| |
| function addData(db) |
| { |
| db.transaction(function(tx) { |
| log("Inserting some data"); |
| // Load a new page while the transaction is still in progress, interrupting the transaction. |
| // This should not leave the database locked and on the next page we should be able to insert |
| // some more data. |
| tx.executeSql("INSERT INTO DataTest (testData) VALUES (ZEROBLOB(524200))", [], |
| function(tx, result) { location.href = "./resources/database-lock-after-reload-2.html"; }, |
| function(tx, error) { errorFunction(error); }); |
| tx.executeSql("INSERT INTO DataTest (testData) VALUES (ZEROBLOB(524200))"); |
| }, errorFunction, function() { finishTest(); }); |
| } |
| |
| function runTest() |
| { |
| if (window.testRunner) { |
| testRunner.clearAllDatabases(); |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| var database; |
| try { |
| database = openDatabase("DatabaseLockTest", "1.0", "Test for database locking", 5242880); |
| } catch (e) { |
| log("Error - could not open database"); |
| finishTest(); |
| } |
| |
| database.transaction(function(tx) { |
| log("Adding a table"); |
| tx.executeSql("CREATE TABLE DataTest (testData)", [], function(tx, result) { }, |
| function(tx, error) { errorFunction(error); }); |
| }, errorFunction, function() { addData(database); }); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <pre id="console"> |
| </pre> |
| </body> |
| |
| </html> |