summaryrefslogtreecommitdiffstats
path: root/dom/quota/test/xpcshell/upgrades/test_upgradeStorageFrom2_2.js
blob: 8f41c05b49484b918c5255d16815b9319dd8772d (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
56
57
58
59
60
61
62
63
64
/**
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

/**
 * This test is mainly to verify UpgradeStorageFrom2_2To2_3 method.
 */

async function testSteps() {
  const packages = [
    // Storage used by FF 68-69 (storage version 2.2).
    "version2_2_profile",
    "../defaultStorageDirectory_shared",
  ];

  function verifyDatabaseTable(shouldExist) {
    let file = getRelativeFile("storage.sqlite");
    let conn = Services.storage.openUnsharedDatabase(file);

    let exists = conn.tableExists("database");
    if (shouldExist) {
      ok(exists, "Database table does exist");
    } else {
      ok(!exists, "Database table does not exist");
    }

    conn.close();
  }

  info("Clearing");

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

  info("Verifying storage");

  verifyStorage(packages, "beforeInstall");

  info("Installing packages");

  installPackages(packages);

  info("Verifying storage");

  verifyStorage(packages, "afterInstall");

  verifyDatabaseTable(/* shouldExist */ false);

  info("Initializing");

  // Initialize to trigger storage upgrade from version 2.2
  request = init();
  await requestFinished(request);

  info("Verifying storage");

  verifyStorage(packages, "afterInit");

  request = reset();
  await requestFinished(request);

  verifyDatabaseTable(/* shouldExist */ true);
}