<!doctype html>
<html>
<head>
<style>
pre { padding: 5px; border: 1px solid black; }
</style>
<script>
var db;
try {
if (window.openDatabase) {
db = openDatabase("StressTest1", "1.0", "Database Stress Test", 200000);
if (!db)
alert("Failed to open the database on disk. This is probably because the version was bad or there is not enough space left in this domain's quota");
} else
alert("Couldn't open the database.");
} catch(err) { }
var highestId = 0;
var allData = new Array();
function newData()
{
var id = ++highestId;
allData.push(id);
db.transaction(function (tx)
{
tx.executeSql("INSERT INTO FillerData (id, filler) VALUES (?, randomblob(1024))", [id]);
});
}
function testOpen()
{
for (var i = 0; i < 4; i++) {
newData();
}
setTimeout("testClose();", 0);
}
function testClose()
{
db.transaction(function(tx)
{
for (var i = 0; i < allData.length; i++)
tx.executeSql("DELETE FROM FillerData WHERE id = ?", [allData[i]]);
allData = new Array();
});
setTimeout("testOpen();", 0);
}
function updateTransactionCount()
{
document.getElementById("transactionCount").innerHTML = "Current Transaction Count: " + highestId;
setTimeout("updateTransactionCount();", 1000);
}
function loaded()
{
db.transaction(function(tx) {
tx.executeSql("SELECT COUNT(*) FROM FillerData", [], function(result) { }, function(tx, error) {
tx.executeSql("CREATE TABLE FillerData (id REAL UNIQUE, filler)", [], function(result) {
});
});
});
setTimeout("testOpen();", 0);
setTimeout("updateTransactionCount();", 1000);
}
addEventListener('load', loaded, false);
</script>
</head>
<body>
This test stresses the database threading code by constantly opening transactions to the test database at a fast rate.<br>
See radar 5729446 for more details.<br>
<pre id="transactionCount">Current Transaction Count: 0</pre>
</body>
</html>