<html>
<head>
<script>

function log(message)
{
    document.getElementById("console").innerHTML += message + "<br>";
}

function finishTest()
{
    log("Test Complete");
    if (window.testRunner)
        testRunner.notifyDone();
}

function errorFunction(error)
{
    log("Test failed - " + error.message);
    finishTest();
}

var successCount = 0;

function successFunction(message)
{
    log("Transaction succeeded - " + message);
    if (++successCount == 2)
        finishTest();
}

function runTest()
{
    if (window.testRunner) {
        testRunner.clearAllDatabases();
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }
    
    var database = openDatabase("SuccessCallbackDatabase", "1.0", "Test for success callback <rdar://5737692>", 1);
    database.transaction(function(tx) { tx.executeSql("CREATE TABLE IF NOT EXISTS SuccessCallbackTest (randomData)", []); }, errorFunction, function() { successFunction("Transaction with one statement"); });
    database.transaction(function(tx) { }, errorFunction, function() { successFunction("Empty transaction"); });
}

</script>
</head>

<body onload="runTest()">
This test confirms that a successful transaction - both with and without a statement - receives its successCallback
<pre id="console">
</pre>
</body>

</html>
