Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / websql / execute-sql-rowsAffected.html
blob89e4cddbe71b1a6193c80be13eb66934c6066e9f
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 </head>
5 <body>
6 <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);
20 function runTest()
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);
38 runTest();
39 window.jsTestIsAsync = true;
40 </script>
42 </body>
43 </body>
44 </html>