tor-browser

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

test_default_journal_size_limit.js (1255B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Tests defaul journal_size_limit
      5 
      6 async function check_journal_size(db) {
      7  let stmt = db.createAsyncStatement("PRAGMA journal_size_limit");
      8  let value = await new Promise((resolve, reject) => {
      9    stmt.executeAsync({
     10      handleResult(resultSet) {
     11        resolve(resultSet.getNextRow().getResultByIndex(0));
     12      },
     13      handleError() {
     14        reject();
     15      },
     16      handleCompletion() {},
     17    });
     18  });
     19  Assert.greater(value, 0, "There is a positive journal_size_limit");
     20  stmt.finalize();
     21  await new Promise(resolve => db.asyncClose(resolve));
     22 }
     23 
     24 async function getDbPath(name) {
     25  let path = PathUtils.join(PathUtils.profileDir, name + ".sqlite");
     26  Assert.ok(!(await IOUtils.exists(path)));
     27  return path;
     28 }
     29 
     30 add_task(async function () {
     31  await check_journal_size(
     32    Services.storage.openDatabase(
     33      new FileUtils.File(await getDbPath("journal"))
     34    )
     35  );
     36  await check_journal_size(
     37    Services.storage.openUnsharedDatabase(
     38      new FileUtils.File(await getDbPath("journalUnshared"))
     39    )
     40  );
     41  await check_journal_size(
     42    await openAsyncDatabase(new FileUtils.File(await getDbPath("journalAsync")))
     43  );
     44 });