3 <script src=
"../../resources/js-test.js"></script>
7 description("This test tests that SQLResultSet.rowsAffected attribute is correct in success callback for executeSql().");
9 function errorCallback(transaction
, error
)
11 testFailed("Database error code: " + error
.code
+ ", message: " + error
.message
);
14 function rowsAffectedShouldBe(resultSet
, expected
)
16 rowsAffected
= resultSet
.rowsAffected
;
17 shouldBe("rowsAffected", expected
);
22 if (window
.testRunner
)
23 testRunner
.clearAllDatabases();
25 db
= openDatabase("RowsAffectedTest", "1.0", "", 1);
26 db
.transaction(function (t
) {
27 t
.executeSql("CREATE TABLE IF NOT EXISTS RowsAffectedTest (Foo INT, text TEXT)");
28 t
.executeSql("INSERT INTO RowsAffectedTest VALUES (1, 'a')", null, function(t
, r
) { rowsAffectedShouldBe(r
, "1"); }, errorCallback
);
29 t
.executeSql("INSERT INTO RowsAffectedTest VALUES (2, 'b')", null, function(t
, r
) { rowsAffectedShouldBe(r
, "1"); }, errorCallback
);
30 t
.executeSql("UPDATE RowsAffectedTest SET text = 'c'", null, function(t
, r
) { rowsAffectedShouldBe(r
, "2"); }, errorCallback
);
31 t
.executeSql("SELECT * FROM RowsAffectedTest", null, function(t
, r
) { rowsAffectedShouldBe(r
, "0"); }, errorCallback
);
32 t
.executeSql("DELETE FROM RowsAffectedTest", null, function(t
, r
) { rowsAffectedShouldBe(r
, "2"); }, errorCallback
);
33 t
.executeSql("DELETE FROM RowsAffectedTest", null, function(t
, r
) { rowsAffectedShouldBe(r
, "0"); }, errorCallback
);
34 t
.executeSql("SELECT * FROM RowsAffectedTest", null, function(t
, r
) { rowsAffectedShouldBe(r
, "0"); }, errorCallback
);
35 }, function(error
) { errorCallback(null, error
); finishJSTest(); }, finishJSTest
);
39 window
.jsTestIsAsync
= true;