tor-browser

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

test_storage_service_unshared.js (1237B)


      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 // This file tests the openUnsharedDatabase function of mozIStorageService.
      6 
      7 function test_openUnsharedDatabase_null_file() {
      8  try {
      9    Services.storage.openUnsharedDatabase(null);
     10    do_throw("We should not get here!");
     11  } catch (e) {
     12    print(e);
     13    print("e.result is " + e.result);
     14    Assert.equal(Cr.NS_ERROR_INVALID_ARG, e.result);
     15  }
     16 }
     17 
     18 function test_openUnsharedDatabase_file_DNE() {
     19  // the file should be created after calling
     20  var db = getTestDB();
     21  Assert.ok(!db.exists());
     22  Services.storage.openUnsharedDatabase(db);
     23  Assert.ok(db.exists());
     24 }
     25 
     26 function test_openUnsharedDatabase_file_exists() {
     27  // it should already exist from our last test
     28  var db = getTestDB();
     29  Assert.ok(db.exists());
     30  Services.storage.openUnsharedDatabase(db);
     31  Assert.ok(db.exists());
     32 }
     33 
     34 var tests = [
     35  test_openUnsharedDatabase_null_file,
     36  test_openUnsharedDatabase_file_DNE,
     37  test_openUnsharedDatabase_file_exists,
     38 ];
     39 
     40 function run_test() {
     41  for (var i = 0; i < tests.length; i++) {
     42    tests[i]();
     43  }
     44 
     45  cleanup();
     46 }