Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / workers / storage / resources / multiple-transactions-on-different-handles-sync.js
1 function runTransaction(db)
2 {
3     db.transaction(function(tx) {
4        // Execute a read-only statement
5        tx.executeSql("SELECT COUNT(*) FROM Test;");
6
7        // Execute a write statement to make sure SQLite tries to acquire an exclusive lock on the DB file
8        tx.executeSql("INSERT INTO Test VALUES (?);", [1]);
9     });
10 }
11
12 var db1 = openDatabaseSync("MultipleTransactionsOnDifferentHandlesTest", "1.0",
13                            "Test transactions on different handles to the same DB.", 1);
14 db1.transaction(function(tx) {
15     tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);");
16 });
17
18 var db2 = openDatabaseSync("MultipleTransactionsOnDifferentHandlesTest", "1.0",
19                            "Test transactions on different handles to the same DB.", 1);
20 if (db1 == db2)
21     postMessage("FAIL: db1 == db2");
22 else {
23     try {
24         runTransaction(db1);
25         runTransaction(db2);
26         postMessage("PASS");
27     } catch (err) {
28         postMessage("FAIL: " + err);
29     }
30 }
31
32 postMessage("done");