summaryrefslogtreecommitdiffstats
path: root/storage/test/unit/test_default_journal_size_limit.js
blob: fa03d9654cee54f42c5bfee7ff412ab5f047c8d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Any copyright is dedicated to the Public Domain.
 * https://creativecommons.org/publicdomain/zero/1.0/ */

// Tests defaul journal_size_limit

async function check_journal_size(db) {
  let stmt = db.createAsyncStatement("PRAGMA journal_size_limit");
  let value = await new Promise((resolve, reject) => {
    stmt.executeAsync({
      handleResult(resultSet) {
        resolve(resultSet.getNextRow().getResultByIndex(0));
      },
      handleError() {
        reject();
      },
      handleCompletion() {},
    });
  });
  Assert.greater(value, 0, "There is a positive journal_size_limit");
  stmt.finalize();
  await new Promise(resolve => db.asyncClose(resolve));
}

async function getDbPath(name) {
  let path = PathUtils.join(PathUtils.profileDir, name + ".sqlite");
  Assert.ok(!(await IOUtils.exists(path)));
  return path;
}

add_task(async function () {
  await check_journal_size(
    Services.storage.openDatabase(
      new FileUtils.File(await getDbPath("journal"))
    )
  );
  await check_journal_size(
    Services.storage.openUnsharedDatabase(
      new FileUtils.File(await getDbPath("journalUnshared"))
    )
  );
  await check_journal_size(
    await openAsyncDatabase(new FileUtils.File(await getDbPath("journalAsync")))
  );
});