summaryrefslogtreecommitdiffstats
path: root/dom/quota/test/xpcshell/test_initializePersistentClient.js
blob: 342fb80171a7d5ab2c5cdea485b169d45123ab2c (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
45
46
/**
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

/**
 * This test is mainly to verify that initializePersistentClient() does call
 * QuotaManager::EnsurePersistentClientIsInitialized() which ensures client
 * directory existence.
 */

async function testSteps() {
  const clientMetadata = {
    persistence: "default",
    principal: getPrincipal("https://foo.example.com"),
    client: "sdb",
    file: getRelativeFile("storage/permanent/https+++foo.example.com/sdb"),
  };

  info("Clearing");

  let request = clear();
  await requestFinished(request);

  info("Initializing");

  request = init();
  await requestFinished(request);

  info("Initializing persistent origin");

  request = initPersistentOrigin(clientMetadata.principal);
  await requestFinished(request);

  ok(!clientMetadata.file.exists(), "Client directory does not exist");

  info("Initializing persistent client");

  request = initPersistentClient(
    clientMetadata.principal,
    clientMetadata.client
  );
  await requestFinished(request);

  ok(clientMetadata.file.exists(), "Client directory does exist");
}