storage/test/unit/test_bug-365166.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 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/licenses/publicdomain/  */ 
     4 // Testcase for bug 365166 - crash [@ strlen] calling
     5 // mozIStorageStatement::getColumnName of a statement created with
     6 // "PRAGMA user_version" or "PRAGMA schema_version"
     7 function run_test() {
     8   test('user');
     9   test('schema');
    11   function test(param)
    12   {
    13     var colName = param + "_version";
    14     var sql = "PRAGMA " + colName;
    16     var file = getTestDB();
    17     var storageService = Components.classes["@mozilla.org/storage/service;1"].
    18                          getService(Components.interfaces.mozIStorageService);
    19     var conn = storageService.openDatabase(file); 
    20     var statement = conn.createStatement(sql);
    21     try {
    22       // This shouldn't crash:
    23       do_check_eq(statement.getColumnName(0), colName);
    24     } finally {
    25       statement.reset();
    26       statement.finalize();
    27     }
    28   }
    29 }

mercurial