summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/sql/data/readonly-error.js
blob: ab82712223a06b69278bfc0de18e36ac7d092552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function test() {
    var r="transaction_not_finished";
    var db = openDatabaseSync("QmlTestDB-readonly-error", "1.0", "Test database from Qt autotests", 1000000);

    db.transaction(
        function(tx) {
            tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
            tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
            r = "passed";
        }
    );

    try {
        db.readTransaction(
            function(tx) {
                tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
                r = "FAILED";
            }
        );
    } catch (err) {
        if (err.message == "Read-only Transaction")
            r = "passed";
        else
            r = "WRONG ERROR="+err.message;
    }

    return r;
}