tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug-444233.js (1426B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 function setup() {
      6  // Create the table
      7  getOpenedDatabase().createTable(
      8    "test_bug444233",
      9    "id INTEGER PRIMARY KEY, value TEXT"
     10  );
     11 
     12  // Insert dummy data, using wrapper methods
     13  var stmt = createStatement(
     14    "INSERT INTO test_bug444233 (value) VALUES (:value)"
     15  );
     16  stmt.params.value = "value1";
     17  stmt.execute();
     18  stmt.finalize();
     19 
     20  stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
     21  stmt.params.value = "value2";
     22  stmt.execute();
     23  stmt.finalize();
     24 }
     25 
     26 function test_bug444233() {
     27  print("*** test_bug444233: started");
     28 
     29  // Check that there are 2 results
     30  var stmt = createStatement("SELECT COUNT(*) AS number FROM test_bug444233");
     31  Assert.ok(stmt.executeStep());
     32  Assert.equal(2, stmt.row.number);
     33  stmt.reset();
     34  stmt.finalize();
     35 
     36  print("*** test_bug444233: doing delete");
     37 
     38  // Now try to delete using IN
     39  // Cheating since we know ids are 1,2
     40  try {
     41    var ids = [1, 2];
     42    stmt = createStatement("DELETE FROM test_bug444233 WHERE id IN (:ids)");
     43    stmt.params.ids = ids;
     44  } catch (e) {
     45    print("*** test_bug444233: successfully caught exception");
     46  }
     47  stmt.finalize();
     48 }
     49 
     50 function run_test() {
     51  setup();
     52  test_bug444233();
     53  cleanup();
     54 }