blob: e68119b196ed8a9e1991b095a2658cdc8de7d1eb [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("This test tests that SQLResultSet.rowsAffected attribute is correct in success callback for executeSql().");
function errorCallback(transaction, error)
{
testFailed("Database error code: " + error.code + ", message: " + error.message);
}
function rowsAffectedShouldBe(resultSet, expected)
{
rowsAffected = resultSet.rowsAffected;
shouldBe("rowsAffected", expected);
}
function runTest()
{
if (window.testRunner)
testRunner.clearAllDatabases();
db = openDatabase("RowsAffectedTest", "1.0", "", 1);
db.transaction(function (t) {
t.executeSql("CREATE TABLE IF NOT EXISTS RowsAffectedTest (Foo INT, text TEXT)");
t.executeSql("INSERT INTO RowsAffectedTest VALUES (1, 'a')", null, function(t, r) { rowsAffectedShouldBe(r, "1"); }, errorCallback);
t.executeSql("INSERT INTO RowsAffectedTest VALUES (2, 'b')", null, function(t, r) { rowsAffectedShouldBe(r, "1"); }, errorCallback);
t.executeSql("UPDATE RowsAffectedTest SET text = 'c'", null, function(t, r) { rowsAffectedShouldBe(r, "2"); }, errorCallback);
t.executeSql("SELECT * FROM RowsAffectedTest", null, function(t, r) { rowsAffectedShouldBe(r, "0"); }, errorCallback);
t.executeSql("DELETE FROM RowsAffectedTest", null, function(t, r) { rowsAffectedShouldBe(r, "2"); }, errorCallback);
t.executeSql("DELETE FROM RowsAffectedTest", null, function(t, r) { rowsAffectedShouldBe(r, "0"); }, errorCallback);
t.executeSql("SELECT * FROM RowsAffectedTest", null, function(t, r) { rowsAffectedShouldBe(r, "0"); }, errorCallback);
}, function(error) { errorCallback(null, error); finishJSTest(); }, finishJSTest);
}
runTest();
window.jsTestIsAsync = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</body>
</html>