storage/test/unit/test_bug-444233.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial