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.

     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/. */
     5 function setup() {
     6     // Create the table
     7     getOpenedDatabase().createTable("test_bug444233",
     8                                     "id INTEGER PRIMARY KEY, value TEXT");
    10     // Insert dummy data, using wrapper methods
    11     var stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
    12     stmt.params.value = "value1"
    13     stmt.execute();
    14     stmt.finalize();
    16     stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
    17     stmt.params.value = "value2"
    18     stmt.execute();
    19     stmt.finalize();
    20 }
    22 function test_bug444233() {
    23     print("*** test_bug444233: started");
    25     // Check that there are 2 results
    26     var stmt = createStatement("SELECT COUNT(*) AS number FROM test_bug444233");
    27     do_check_true(stmt.executeStep());
    28     do_check_eq(2, stmt.row.number);
    29     stmt.reset();
    30     stmt.finalize();
    32     print("*** test_bug444233: doing delete");
    34     // Now try to delete using IN
    35     // Cheating since we know ids are 1,2
    36     try {
    37         var ids = [1, 2];
    38         stmt = createStatement("DELETE FROM test_bug444233 WHERE id IN (:ids)");
    39         stmt.params.ids = ids;
    40     } catch (e) {
    41         print("*** test_bug444233: successfully caught exception");
    42     }
    43     stmt.finalize();
    44 }
    46 function run_test() {
    47     setup();
    48     test_bug444233();
    49     cleanup();
    50 }

mercurial