Html程序  |  47行  |  1.31 KB

<html>
<head>
<script>
function finishTest()
{
    if (window.layoutTestController)
        layoutTestController.notifyDone();
}

function runTest()
{
    if (window.layoutTestController) {
        layoutTestController.clearAllDatabases();
        layoutTestController.dumpAsText();
        layoutTestController.waitUntilDone();
    }

    try {
        var db = openDatabase("NullCallbacks", "1.0", "Test for null callbacks.", 1);
        db.transaction(function(tx) {
            tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo INT)", null);
            tx.executeSql("INSERT INTO Test VALUES (?)", [1], null, null);
            tx.executeSql("INSERT INTO Test VALUES (?)", [2], null);
            tx.executeSql("INSERT INTO Test VALUES (3)", null, null, null);
            tx.executeSql("INSERT INTO Test VALUES (?)", [4], null,
                function(tx, error) {});
        }, null, null);

        db.transaction(function(tx) {
            tx.executeSql("INSERT INTO Test VALUES (?)", [5]);
        }, null, function() { finishTest(); });
    } catch(err) {
        document.getElementById("console").innerHTML = "FAIL";
        finishTest();
    }
}

</script>
</head>

<body onload="runTest()">
This test checks that 'null' can be used wherever we expect an optional callback.
<pre id="console">PASS</pre>
</body>

</html>