| OLD | NEW |
| 1 // Copyright 2008, Google Inc. | 1 // Copyright 2008, Google Inc. |
| 2 // | 2 // |
| 3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
| 4 // modification, are permitted provided that the following conditions are met: | 4 // modification, are permitted provided that the following conditions are met: |
| 5 // | 5 // |
| 6 // 1. Redistributions of source code must retain the above copyright notice, | 6 // 1. Redistributions of source code must retain the above copyright notice, |
| 7 // this list of conditions and the following disclaimer. | 7 // this list of conditions and the following disclaimer. |
| 8 // 2. Redistributions in binary form must reproduce the above copyright notice, | 8 // 2. Redistributions in binary form must reproduce the above copyright notice, |
| 9 // this list of conditions and the following disclaimer in the documentation | 9 // this list of conditions and the following disclaimer in the documentation |
| 10 // and/or other materials provided with the distribution. | 10 // and/or other materials provided with the distribution. |
| (...skipping 118 matching lines...) Show 10 above Show 10 below |
| 129 }); | 129 }); |
| 130 }); | 130 }); |
| 131 } | 131 } |
| 132 | 132 |
| 133 function testStatementArguments() { | 133 function testStatementArguments() { |
| 134 withDb(function(db) { | 134 withDb(function(db) { |
| 135 db.synchronousTransaction(function(tx) { | 135 db.synchronousTransaction(function(tx) { |
| 136 // valid arguments | 136 // valid arguments |
| 137 tx.executeSql('SELECT * FROM Pages WHERE pageId = ? and version = ?', | 137 tx.executeSql('SELECT * FROM Pages WHERE pageId = ? and version = ?', |
| 138 [ 1972, '1.0.0.0' ]); | 138 [ 1972, '1.0.0.0' ]); |
| 139 // arguments with null |
| 140 tx.executeSql('SELECT * FROM Pages WHERE pageId = ? and version = ?', |
| 141 [ 1972, null ]); |
| 142 // null arguments |
| 143 tx.executeSql('SELECT * FROM Pages', null); |
| 144 // invalid arguments: function |
| 145 assertError(function() { |
| 146 tx.executeSql('SELECT * FROM Pages WHERE pageId = ? and version = ?', |
| 147 [ function() {}, '1.0.0.0' ]); |
| 148 }, null, 'Function arguments are not allowed'); |
| 149 // invalid arguments: object |
| 150 assertError(function() { |
| 151 tx.executeSql('SELECT * FROM Pages WHERE pageId = ? and version = ?', |
| 152 [ { you: 'is wrong' }, '1.0.0.0' ]); |
| 153 }, null, 'Function arguments are not allowed'); |
| 139 }); | 154 }); |
| 140 }); | 155 }); |
| 141 } | 156 } |
| 142 | 157 |
| 143 function testSQLTransactionApiSig() { | 158 function testSQLTransactionApiSig() { |
| 144 withDb(function(db) { | 159 withDb(function(db) { |
| 145 var method = 'SQLTransaction.executeSql'; | 160 var method = 'SQLTransaction.executeSql'; |
| 146 db.transaction(function(tx) { | 161 db.transaction(function(tx) { |
| 147 assert(tx.executeSQL, method + ' should be present'); | 162 assert(tx.executeSQL, method + ' should be present'); |
| 148 }); | 163 }); |
| 149 }); | 164 }); |
| 150 } | 165 } |
| 151 | 166 |
| 152 function withDb(fn, version) { | 167 function withDb(fn, version) { |
| 153 db_manager && fn && fn.call( | 168 db_manager && fn && fn.call( |
| 154 this, db_manager.openDatabase('unit_test_db', version || '')); | 169 this, db_manager.openDatabase('unit_test_db', version || '')); |
| 155 } | 170 } |
| 156 | 171 |
| OLD | NEW |