tor-browser

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

test_cert_storage_preexisting.js (1670B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 "use strict";
      6 
      7 // This file tests that cert_storage correctly persists its "has prior data"
      8 // information across runs of the browser.
      9 // (The test DB files for this test were created by running the test
     10 // `test_cert_storage_broken_db.js` and copying them from that test's profile
     11 // directory.)
     12 
     13 /* eslint-disable no-unused-vars */
     14 add_task(async function () {
     15  let dbDirectory = do_get_profile();
     16  dbDirectory.append("security_state");
     17  let dbFile = do_get_file("test_cert_storage_preexisting/data.safe.bin");
     18  dbFile.copyTo(dbDirectory, "data.safe.bin");
     19 
     20  let certStorage = Cc["@mozilla.org/security/certstorage;1"].getService(
     21    Ci.nsICertStorage
     22  );
     23  let hasPriorRevocationData = await new Promise(resolve => {
     24    certStorage.hasPriorData(
     25      Ci.nsICertStorage.DATA_TYPE_REVOCATION,
     26      (rv, hasPriorData) => {
     27        Assert.equal(rv, Cr.NS_OK, "hasPriorData should succeed");
     28        resolve(hasPriorData);
     29      }
     30    );
     31  });
     32  Assert.equal(
     33    hasPriorRevocationData,
     34    true,
     35    "should have prior revocation data"
     36  );
     37 
     38  let hasPriorCertData = await new Promise(resolve => {
     39    certStorage.hasPriorData(
     40      Ci.nsICertStorage.DATA_TYPE_CERTIFICATE,
     41      (rv, hasPriorData) => {
     42        Assert.equal(rv, Cr.NS_OK, "hasPriorData should succeed");
     43        resolve(hasPriorData);
     44      }
     45    );
     46  });
     47  Assert.equal(hasPriorCertData, true, "should have prior cert data");
     48 });