| 1 | .import QtQuick.LocalStorage 2.0 as Sql |
| 2 | |
| 3 | function test() { |
| 4 | var r="transaction_not_finished"; |
| 5 | var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-readonly-error", "1.0", "Test database from Qt autotests", 1000000); |
| 6 | |
| 7 | db.transaction( |
| 8 | function(tx) { |
| 9 | tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); |
| 10 | tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); |
| 11 | } |
| 12 | ); |
| 13 | |
| 14 | try { |
| 15 | db.readTransaction( |
| 16 | function(tx) { |
| 17 | tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); |
| 18 | r = "FAILED"; |
| 19 | } |
| 20 | ); |
| 21 | } catch (err) { |
| 22 | if (err.message == "Read-only Transaction") |
| 23 | r = "passed"; |
| 24 | else |
| 25 | r = "WRONG ERROR="+err.message; |
| 26 | } |
| 27 | |
| 28 | return r; |
| 29 | } |