summaryrefslogtreecommitdiffstats
path: root/dom/quota/test/xpcshell/test_initializeTemporaryClient.js
blob: f721560bda65cefa627236ac98c0bc0bec042163 (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
47
48
49
50
51
52
53
54
55
/**
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

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

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

  info("Clearing");

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

  info("Initializing");

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

  info("Initializing temporary storage");

  request = initTemporaryStorage();
  await requestFinished(request);

  info("Initializing temporary origin");

  request = initTemporaryOrigin(
    clientMetadata.persistence,
    clientMetadata.principal
  );
  await requestFinished(request);

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

  info("Initializing temporary client");

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

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